Technical Writer, Production Support, Software Training

Building EBooks with InDesign – Forced Line Breaks


Updated 3-Jan-2012 / Postscript added

One of the pitfalls of converting print publications to EBooks, is that designers often use forced line breaks (Shift+Return/Enter) in print-layouts to control where headings and even paragraph lines are broken. Doing so can cause problems when the same document is also converted to EPUB later on. Problems can occur when we leave the line breaks in the document, but also when we simply opt to remove them. Let’s have a look at what issues we encounter… and how we can fix things in InDesign without altering our layout 🙂 prior to EPUB export.

EPUB Export Options dialog

The EPUB Export dialog provides us with an option to Remove these Forced Line Breaks on the fly if preferred.

Show hidden characters displays forced line breaks in InDesign text

Forced line breaks in InDesign document (Colour code explained later on).

Let’s assume we are working with a publication that has been originally prepared for Print and must now be converted for EBook publishing (be it for EPUB or Kindle)… what happens to the forced line breaks that were inserted?

  1. if we opt to leave the forced line breaks in the InDesign document
  2. if we opt to remove them from the InDesign document

1. Retain Forced Line Breaks during EPUB export

What happens when we export the EPUB and retain the forced line breaks? Well in a nutshell, the resulting HTML will include  <br /> characters. And with altering font-size these characters might generate some very unpredictable (read: unwanted) line breaks in our text.

Resulting BR elements in EPUB export from InDesign

Break characters inserted in EPUB HTML.

 Forced line breaks pointed out in screenshot

 Some unwanted line breaks appearing in the EBook.

 2. Remove Forced Line Breaks during EPUB export

Looking at the example above, it seems clear that you’d want to remove the forced line breaks during export right? So let’s see what else can happen.

Some line breaks ok, some not.

 Possible result in EBook after line break removal (some ok, some not ok).

Yup, you’re not seeing things… (image above). Removing the forced line breaks can result in words being ‘fused’ together. Why does this happen in some cases and not others? Well, it’s all to do with the way the designer originally inserted the forced line breaks in InDesign:

  • Recommended is to place the cursor in front of the character that needs to be moved to the next line, then press Shift+Return/Enter (GREEN). This retains the preceding space.
  • Unfortunately this doesn’t always happen and in quite a few jobs I’ve worked on I encounter ‘missing’ spaces. In this case the space character between two words might have been highlighted when Shift+Return/Enter was pressed or the cursor was inserted at the end of a word when Shift+Return/Enter was pressed and then the leading space on the next line was removed manually. (RED)

No matter what happened, the removal of the space character as part of the forced line break insertion is causing a problem. So it’s important that we check our document for missing preceding spaces and fix things before we export our InDesign file to EPUB.

GREP Find/Change to the rescue

My preferred export way is to have the remove forced line break option enabled… it means less work in EPUB editing… IF we apply one essential step first before we export our InDesign document.

Basically we want to look for any forced line breaks in our document that are NOT preceded by a space character, and then we’d like to insert a space character in front of this break.

Tip: If you find yourself performing a ton of these Find/Changes prior as part of the EBook clean-up… consider purchasing Multi-Find Change plug-in for InDesign and you’ll be able to store all your EBook clean-up Find/Changes in a single set and apply them all in one hit 🙂 see: www.automatication.com

Here we go…

Find what?

  • Any character that is NOT a space: “\S
  • But we need to put it in a marking sub-expression, so we can put the character we found back in the text later on 😉 : “(\S)
  • Next we go look for the forced line break: “\n”

So our Find what string ends up looking like: “(\S)\n”

(\S)\n entered in Find what field.

Change to?

We now need to change things to:

  • The non-space character we found earlier with the first sub-expression, so we don’t end up losing that character from the text 😉 : “$1” (Found > Found  1)
  • Followed by a space-character followed again by the Forced Line Break: “ \n

So our Change to string ends up looking like: “$1 \n

$1 \n set in Change to field.

Next click the Change All button in the Find/Change dialog and…

You can now safely Remove all Forced Line Breaks when exporting your InDesign document to EPUB. Best bit about this: There  is no need to fiddle  with <br /> tags in the HTML afterwards 🙂

Postscript – Removing Selected Forced Line Breaks only

Doug (comments below) mentions that there are indeed cases where you’d like to retain the Forced Line Breaks. Poetry for example. In that case you’d probably be more likely to remove the forced line breaks all together in InDesign for those paragraphs that are NOT  poetry :), and opt not to remove them during the EPUB export. Once again I’m a big fan of trying to get the export as clean as possible from InDesign so there’s less to do with HTML/CSS later on. The one side-note here is that removing those forced line breaks would result in text reflow in the InDesign document. So if you’re looking at a single InDesign file for Print and EBook export, you’ll need to refrain yourself from using forced line breaks as a designer 🙂 As Keith mentions in his comment below. You could  apply a ‘no break’ as an alternative.

Assuming you find yourself working with a document that has its text formatted with paragraph styles, you can selectively replace the forced line breaks in the text and replace them by a single space. We’ll cover both the scenario where we don’t have a preceding space and do have a preceding space in a single Find/Change action.

Find/Change replace All forced line breaks with a single space

Once again we look for

  • any non-space character ‘ \S’ followed by a forced line break ‘\n’  OR ‘|’
  • any space character ‘\s’ followed by a line break ‘\n’

If we turn the non-space character and space character into a Marking subexpression ‘()’, we can then set our Change to to just ‘$1’ 🙂

The only thing we still need to do is set the Find Format. If you don’t see this option in the Find/Change dialog, click the More Options button.

Find what: (\S)\n|(\s)\n

  • Click the Specify Attributes to Find button
  • In the Find Format Settings dialog choose the Paragraph Style for which you want to apply this Find/Change.
  • And once again click Change All.

You’d need to repeat this Find/Change query for each relevant paragraph style.

Note: Tina Hender (@tinahender) tweets, that forced line breaks are also used for URL breaks. My guess would be that in this case you’re likely to see the forced line break at a ‘/’. I’d opt to perform a Find/Change that fixes these first of all. Again… Multi-Find Change for pre-EPUB clean-up will become a handy tool, as you can build this massive Find/Change Query Set in which a multitude of queries are run in one hit 😉

Similar posts
  • Adobe InDesign and XML: A Reference Guide The following is a reference guide I have compiled over time for those of you who are looking at doing a little more with XML in InDesign (originally published Feb. 2011, last updated Feb 2018). If you have any extra information you’d like to see added to this guide, feel free to message me. Mapping XML tags to InDesign [...]
  • How to change the colour of bullet points in InDesig... A few weeks ago I recorded a short quick tip tutorial. InDesign’s Control panel, gives users a quick and easy way to format text as a bulleted list. Highlight the text, and click the Bulleted List button in the Paragraph Formatting Controls mode for the Control panel. This applies a universal bullet character as the [...]
  • Creating a pop-up window in a PDF with Adobe InDesig... In the following YouTube tutorial, we’ll create an interactive PDF from Adobe InDesign, in which we click on a button, which in turn opens up a simple pop-up window containing a close-box. When the close-box is clicked the pop-up window disappears [...]
  • InDesign: Facing pages with odd-numbered left pages Back in 2004 I wrote a tip for InDesign CS on how you could have the first page of your document be a left page AND have it start with page number 1. It’s hard to believe this is almost a decade ago… But a recent question on Facebook, made me think I should really [...]
  • Negative Lookbehind – GREP for Designers This is the fourth and final blog-posts in a series of posts on lookaheads and lookbehinds in GREP, written after speaking at the Perth InDesign User Group. My speaker notes are also available: What is GREP? (PDF download) (2.4Mb). In the previous three posts I briefly introduced GREP, and we took a look at Positive [...]

18 Comments

  1. August 13, 2018    

    I see you don’t monetize your site, don’t waste your traffic, you can earn additional bucks every month.
    You can use the best adsense alternative for any type of website (they approve all websites), for more info simply search
    in gooogle: boorfe’s tips monetize your website

  2. February 16, 2018    

    I see you don’t monetize your site, don’t waste your traffic,
    you can earn extra bucks every month because you’ve got hi quality content.

    If you want to know how to make extra bucks, search for: Ercannou’s essential tools best adsense alternative

  3. Rohit Rohit
    April 15, 2013    

    Hi Cari,

    Thanks for the update.

    Rohit

  4. April 13, 2013    

    Hi Rohit,

    That can be done using a JavaScript for InDesign. It automatically looks for end of lines and then inserts a forced line break. I have heard of a script that’s around that does that, but a quick search didn’t find one online.

    You might want to post this question in the InDesign Scripts forum:
    http://forums.adobe.com/community/indesign/indesign_scripting
    Someone might be kind enough to write this for you or point you to a forum post that already contains this.

    Cari

  5. Rohit Rohit
    April 12, 2013    

    Hi
    I am Rohit From India i have a some problem.

    I want to insert the line break in end of the all lines in the paragraph.

  6. May 28, 2012    

    @Ishak

    You’d need to create a Fixed Layout EPUB. There’s different ways of doing that. You can break your InDesign document into individual pages and combine these in the Book panel, then export to HTML, and you’d need to edit the CSS to control where your content appears (you also need to change some other settings in the EPUB itself) … For info on Fixed Layout EPUBs: http://idpf.org/epub/fxl/.

    Alternatively you could create images for each InDesign page and use those, this would retain the layout, but the document wouldn’t be accessible as your text will be rasterised.

    Cari

  7. Ishak Ishak
    May 9, 2012    

    Hi

    can anyone explain me that which indesign “break up” will help to keep the text as laid out in the indesign while exporting as ePub.

  8. Chloe Chloe
    March 16, 2012    

    I’m doing a layout that involves a line of text in a foreign script (Gurmukhi), followed by a line or two of transliteration to show how it’s pronounced, followed by the English translation. Each paragraph has all 3 elements.

    Ideally, I would like to have all 3 elements of a paragraph on one page and tell it not to have the epub break in the middle of ANY of the paragraphs but only between paragraphs.

    Any thoughts on how I could manage that?

    • March 17, 2012    

      Try wrapping those bits of text you want to keep together in a separate <div>, add a class, and in the css include: page-break-inside:avoid; also you include page-break-before:always; to force the block of text to move to the next page. Please note though that these tricks don’t work for all eReader devices, I recommend you test on the device you’re developing for.

      E.g.:
      div.keeptogether {
      page-break-before:always;
      page-break-inside:avoid;
      }

      and in html:

      <div class="keeptogether">
      ... content here ...
      </div>

  9. Neil Neil
    January 26, 2012    

    I do a lot of poetry book conversions from ID to ePub and this blog is going to be a godsend to me.. Likeminded people, wow.

    The earlier comment about designers ‘not like us’really resonates.

    • February 17, 2012    

      Thanks Neil… I’ve been pretty busy lately… hence no more than one post added for the year… but keep an eye out after mid next week for some new stuff 🙂

  10. January 3, 2012    

    @Doug

    Ha, poetry… I’ve managed to stay away from that thus far 🙂 But poetry to EPUB is tricky. 🙂
    In that case you’d leave the forced-line-breaks in during export to EPUB.

    However, if you were to use a separate paragraph style to set poetry, you could still use the GREP Find/Change trick, but this time to entirely remove the unwanted forced line breaks in InDesign and replace them with a space (this does mean you’ll see some text reflow in the InDesign document where the forced line breaks are removed).

    Ensure you set the ‘Paragraph Styles\’ in the Find Format for which you DO want to perform this particular fix. You’d need to run one query for each paragraph style (unless you use Multi-Find/Change – see link above – and create a query set).

    Find what: ‘(\S)\n’
    Change to: ‘$1 ‘

    p.s. I’ve added a Postscript to my blogpost Doug 🙂 In which I describe how you can remove forced line breaks in selected paragraphs only before EPUB export 🙂

  11. January 3, 2012    

    @Keith I try and teach people to be cautious with using soft-returns, but old-habits seem to die hard 🙂 It’s quite amazing what I see in documents at times 🙂 If the print-layout needs to be retained, I’d opt to leave the soft-returns in the document, but ensure they are preceded by a space. As Naomi points out, you’d need to consider whether there are other occurrences that you’ve not accounted for (e.g. hard-hyphens inserted by a designer to ‘hyphenate’ words)

  12. January 2, 2012    

    This can get tricky when a book contains poetry or song lyrics. Poetry is often entered with each stanza as a paragraph and each line within the stanza having a hard return at the end. We wouldn’t want to remove the forced line breaks in that case because it would destroy the poetry’s structure. So we either have to not use that feature or change the way the poetry is styled.

    Unfortunately, I haven’t found an ideal solution yet to format poetry well and also avoid fiddling with the ePub markup to correct it or fix other markup problems caused be keeping the line breaks to make the poetry work.

  13. January 2, 2012    

    Two of my examples of weird characters not used elsewhere rendered as question marks, but hopefully the idea still comes across.

  14. January 2, 2012    

    Designers who aren’t us cause SO many problems…

    If I may offer a couple more tricks along these lines?

    You can also replace all the soft-returns with spaces, and then replace all double-spaces with single-spaces–or replace all soft-returns with some weird character not used elsewhere ( ß ? ? ) and then replace weird-character+space with just the space.

    If you’re the person making the print file, it’s good practice to avoid soft-returns in body copy altogether by creating a “no break” character style and applying it to the words causing the bad rags. In addition to making epub export easy (you just delete the character style), it also doesn’t override InDesign’s excellent type-spacing algorithms.

  15. January 2, 2012    

    Hi Naomi,
    That’s a valid point indeed 🙂
    Problem I have with those is that the only way to tell whether they are ‘hard-hyphens’ that should become discretionary hyphens is by reviewing the text itself after ‘space-insertion’ … I tend to run a document wide Find/Change for ‘hyphen followed by space’ after… using the Find, then Find Next option… so I can review each of those. Luckily I don’t come across those too often 🙂 as most documents I work on have hyphenation disabled…
    Cari

  16. January 2, 2012    

    Watch out for forced hyphenation though. Some designers use hard hyphens and forced line breaks instead of discretionary hyphens (which also need to be removed).

Leave a Reply

Your email address will not be published. Required fields are marked *