Skip to main content
Participant
March 16, 2022
Question

EPUB TOC creating page numbers for each line of text

  • March 16, 2022
  • 1 reply
  • 401 views

Hey.

I am formatting an EPUB. The chapter headings for each chapter contain a number and a line of text with the name of the chapter (or in some cases, two lines of text):

 

When exported as an EPUB, the TOC gives each line its own page number, like this:

 

I can't find any information on how to solve this problem. I'd greatly appreciate any help on this.

Thanks so much!

This topic has been closed for replies.

1 reply

Willi Adelberger
Community Expert
Community Expert
March 16, 2022

I suppose you have created for each line its own paragraph. Make one single paragraph for these lines and they appear together with one entry in the toc.

To keep text together in one line use non breaking spaces, to get a new line, not a new paragraph, use shift return.

James Gifford—NitroPress
Legend
March 16, 2022

Almost certainly that.

 

Soft returns/newlines are something of a glitch in reflowable EPUB; there's a checkbox to remove them for a fairly good reason.

 

The better techniques for controlling line breaks, especially for chapter headings, is to specify left/right margins or use nonbreaking spaces very selectively. In this case, a hard space between the words "MR.[hard space]MCGRATH[hard space]REFUSES[soft space]AN[hard space]INVITATION" would probably work best, but 5-10% side margins might work almost as well. Or in combination.

 

The attached chapter number is a problem. Only a soft return can create that alignment and create a proper TOC entry. There are other formatting techniques that might work better, such as two styles.

 

After some tinkering, it looks as if the only way to create the style shown and have a matching TOC is:

  1. Use two styles for the chapter number and chapter title.
  2. Set the chapter title margins to help fold the text, and selective use of hard spaces to hold text together.
  3. In the TOC, ignore the chapter number style and auto-number the chapter entries to match.

 

Participant
March 16, 2022

Hi. In the end, it's like you both suggested - a combination of soft returns and (aggressive) margins.

Thank you so much. It's really apreciated. Have a great week!