Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 01-16-2016, 01:06 AM   #1
democrite
Evangelist
democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.
 
Posts: 441
Karma: 77256
Join Date: Sep 2011
Device: none
Aligned chapter numbers in a TOC

Hello,

I have an HTML TOC that looks something like this:

I. – Title
II. – Title
III. – Title
IV. – Title


I'm trying to get the chapter numbers aligned by the endash as well as having the chapter title left aligned, if it wraps, after the endash. I have the chapter numbers in a span:

Code:
<div class="sgc-toc-level-2">
  <a href=""><span class="num">XXXVII. – </span> Title</a>
</div>
Code:
.num { width:5.5em; text-align:right; float:left; padding-right:.5em }
It looks ok in ADE yet in iBooks, the chapter title wraps and begins at the left margin. A hanging indent doesn't seem to work.
democrite is offline   Reply With Quote
Old 01-16-2016, 03:39 AM   #2
GrannyGrump
Obsessively Dedicated...
GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.
 
GrannyGrump's Avatar
 
Posts: 3,221
Karma: 35037583
Join Date: May 2011
Location: PA {back in the usa!}
Device: Sony PRS-T2, ADE on PC
You might try an Ordered List with Roman Numerals.
http://www.w3schools.com/html/html_lists.asp

I don't know if iBooks will honor that, but maybe worth a try.
GrannyGrump is offline   Reply With Quote
Old 01-16-2016, 03:43 AM   #3
democrite
Evangelist
democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.
 
Posts: 441
Karma: 77256
Join Date: Sep 2011
Device: none
I had briefly considered that, though if I have multiple sections, each with a set of chapters, the number of chapters differ and I don't think alignment by the endash or chapter title would work between sections. A table is another idea though I'm trying to stay away from that.
democrite is offline   Reply With Quote
Old 01-16-2016, 04:04 AM   #4
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,548
Karma: 19500001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
I wouldn't advise using lists, ordered or unordered, styling options are limited in ePub2 and support is sloppy.

It might be possible to use some combination of left margin for the titles, and relative positioning for the numbers (maybe with width:0 or display:inline-block). But it seems alignment is wrong. This works in the browser, though, and doesn't use non-ePub2 CSS:

https://jsfiddle.net/jm2j8kmn/
Jellby is online now   Reply With Quote
Old 01-16-2016, 04:36 AM   #5
democrite
Evangelist
democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.
 
Posts: 441
Karma: 77256
Join Date: Sep 2011
Device: none
Thank you Jellby. That looks perfect. ADE didn't like it very much, and iBooks had a slight indent for the title which I might have been able to fix with adjusting the left margin.

A hanging indent did end up working.

Code:
div.sgc-toc-level-2 	{ text-indent:0; margin-left:5.5em }
.num 			{ width:5.5em; text-align:right; float:left; padding-right:.5em; margin-left:-6em }
https://jsfiddle.net/znwbre26/2/
democrite is offline   Reply With Quote
Old 01-16-2016, 09:23 AM   #6
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,764
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by democrite View Post
Thank you Jellby. That looks perfect. ADE didn't like it very much, and iBooks had a slight indent for the title which I might have been able to fix with adjusting the left margin.

A hanging indent did end up working.

Code:
div.sgc-toc-level-2 	{ text-indent:0; margin-left:5.5em }
.num 			{ width:5.5em; text-align:right; float:left; padding-right:.5em; margin-left:-6em }
https://jsfiddle.net/znwbre26/2/
Hmmm, what about using a table for that? A two column table with "text-align: right" for the first column and "text-aling: left" for the second column could work. For example this code works fine under ADE:

Code:
td {
   text-align: left;
   vertical-align: top;
}

td.first {
   text-align: right !important;
}
and

Code:
  <table width="100%" cellspacing="10" cellpadding="0" border="0">
    <tr>
      <td class="first">I.&nbsp;—&nbsp;</td>

      <td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ac tellus nunc. Phasellus imperdiet leo metus, et gravida lacus.</td>
    </tr>

    <tr>
      <td class="first">II.&nbsp;—&nbsp;</td>

      <td>Title</td>
    </tr>

    <tr>
      <td class="first">III.&nbsp;—&nbsp;</td>

      <td>Title</td>
    </tr>

    <tr>
      <td class="first">…</td>

      <td>&nbsp;</td>
    </tr>

    <tr>
      <td class="first">XXXVIII&nbsp;—&nbsp;</td>

      <td>Title</td>
    </tr>
  </table>
Here there are two screenshots of ADE (with different font-size):

Click image for larger version

Name:	Image1.png
Views:	274
Size:	33.3 KB
ID:	145589 Click image for larger version

Name:	Image2.png
Views:	275
Size:	43.5 KB
ID:	145590

Below you can check the respective epub.

NOTE: As you can see, I styling "inline" the table; that is because ADE has "issues" with styling tables with code in the .css stylesheet.

Regards
Rubén
Attached Files
File Type: epub Aligned chapter numbers in a TOC.epub (2.3 KB, 273 views)
RbnJrg is offline   Reply With Quote
Old 01-16-2016, 02:04 PM   #7
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,548
Karma: 19500001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
How does ADE handle page breaking in tables?
Jellby is online now   Reply With Quote
Old 01-16-2016, 04:20 PM   #8
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,764
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Jellby View Post
How does ADE handle page breaking in tables?
Perfectly fine; at least, in ADE 3.0 or upper. Watch the following screenshots:

Click image for larger version

Name:	Image1.png
Views:	248
Size:	47.3 KB
ID:	145596 Click image for larger version

Name:	Image2.png
Views:	278
Size:	24.6 KB
ID:	145597
RbnJrg is offline   Reply With Quote
Old 01-16-2016, 07:17 PM   #9
democrite
Evangelist
democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.democrite will give the Devil his due.
 
Posts: 441
Karma: 77256
Join Date: Sep 2011
Device: none
Thanks for all the code RbnJrg. I had considered a table and it might have taken me a few minutes of regex to setup though I was avoiding it. I have used tables in the past for lists when there wasn't other options, like if I wanted right-aligned section #'s for instance. I vaguely recall long ago I had trouble with minor appearance issues but maybe that was long ago and recent times I've tried it worked well. I wasn't sure if a cell with a paragraph set to page-break-after:avoid, would work, though it would have been quick to test. I was just staying away from tables for some reason, maybe the more complicated code, or merely than adding one or two spans was more elegant.
democrite is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Poetry: line numbers aligned to the right. 1v4n0 ePub 20 12-16-2017 04:02 AM
Chapter Page Numbers Instead of Title Page Numbers TheArtfulDodger Devices 1 11-18-2013 01:08 PM
Kobo (touch?) page numbers per chapter Mrs_Often Kobo Reader 11 09-12-2012 06:03 PM
chapter numbers are graphical alansplace Sigil 6 07-04-2011 10:10 AM
fixing up chapter numbers cybmole Sigil 4 01-12-2011 02:49 AM


All times are GMT -4. The time now is 08:51 AM.


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