Join Anne-Marie Concepción for an in-depth discussion in this video Setting text wrap rules, part of InDesign CS4: EPUB Kindle and iPad.
Another way to create interest in your EPUBs and to call attention to special chunks of text or images is to set them off with this kind of text wrap effect that we are looking at. Notice that as I resize this that the text wrap maintains. How do you make that kind of text wrap? Well it's not something that you can do in InDesign and expect to be supported in the resulting EPUB without any kind of intervention. Unfortunately, we always hope that the next version of InDesign will actually convert these correctly.
When I actually created this in InDesign and exported to EPUB, this is after I fiddled around with the CSS. Before I fiddled around with CSS, it looked like this, all right? So it wasn't too exciting. In fact you don't need to do anything really in InDesign. If while you're looking at it, you are like you know what this would look better in a little sidebar box that the text wraps around. You can do it yourself very easily in XHTML. And it doesn't just have to be a text frame that other text runs around.
It could be an image that other text runs around. So let's take a look at the starting files here. In the Finder, I have in the Exercise Files we were just looking at the final one. This is an EPUB file that's been expanded to its component parts and in the beginning we are going to look at the before version and then I will show you how you can make that interesting runaround box. Inside the OEBPS folder you need to open up the XHTML file that you want to include that runaround in and the CSS file. That remember the CSS file has all the formatting instructions.
So I am Shift+clicking both of these and I am going to open them in TextWrangler and you can actually edit these in any one of your favorite editing programs. I just happen to have TextWrangler open. So first actually let's look at the XHTML file and let me turn on Wrap Text and we will find this guy. It's down here. It's simply a side-box div and if you are not into CSS I just said gobbledygook, but this is basically you surround the text that you want to have in a floating sidebar with a tag called a div and it has to have a class and then you give the class a name.
Now if you had actually embedded a text frame with an object style in here, as I mentioned in the previous video when we were talking about pull quotes, then InDesign will automatically add these tags for you with the same name as the object style. But you don't have to think that much ahead. You can actually do it right here. You could type in div class= and then type in anything that you like. And then you close it with a slash mark and a div at the end of where you want that box to end. There is two parts. You have to have the tags in the XHTML file and then you have to have the tags in the CSS file and in the CSS file is where you actually give it some attributes.
So that's why it looks so plain right now, what we were just looking at in Safari, because it has no attributes. So we are going to go ahead and add them. I do have, as you saw, I have the final version of this in the Exercise Files. So you could always go inside there and grab that template.css, which has everything I am about to type out here. So you don't have to go crazy, madly scribbling down everything you are watching on the video as I enter it. But the main thing is that we don't want the box to take up the entire width of the window. We want it to take up a percentage of the window and because we don't know where this EPUB is going to be read, on an iPhone, on a Galaxy, on an iPad, whatever, we can't really specify it in number of pixels or even ems.
We are going to give it a percentage. So we want the width of this box, width, to be 50%, 30%, whatever you'd like and then here's the magic part that makes it actually text wrap. It's the float command and if you watch the video on drop caps that's how we got the text to run around that letter, by assigning a float to it. So we are going to float this box on the left. We will do left, but you could do right if you want to.
And then we are going to go ahead and add the same kind of things that we added to our pull quotes. So I am going to say we want a little line around it because I am a big fan of borders and we'll just say gray border. You could put in any normal color or you could put in a hex code here. Don't forget your semicolons at the end and border-style: solid and the width of that border, because if you forget this they come out really thick and clunky looking. border-width: 1px and now you need to add some air around this thing.
margin, starting from the top of this box and then at 12 o'clock and then I'm moving to 3 o'clock, 6 o'clock and 9 o'clock, so top, right, bottom, left. We are going to put that we don't need space above it, so we will just put zero and if it's zero, you don't even have to write em. Just type a space and we will put on the right-hand side, remember because it's floating on the left, so on the right- hand side we want some space and let's try .75em and then we don't need any other space. That looks good.
We want to add some padding. That's like the text-inset if you remember from the pull quote video. padding, I'll just do 0.5em and let's save our changes. And then we are going to preview this in the browser. So I am going to select this and right-click and say Open With > Safari and there it is. I am going to make sure we have the latest version by clicking Refresh. There is our little floating box nickel.
And do you remember how to make a background color? We want to add a background color. So if I come over here back to TextWrangler and we want to add one ore attribute here. Call it background-color. Let's choose an interesting background color. My favorite way of choosing a hex color is just to jump into Photoshop, assuming it's running. And click on the Photoshop Color Picker and then from this wonderful Color Picker dialog box, let's try one of these guys down here like this and then maybe out here a bit and then here is the little hex code that we need to copy.
So you select it, copy it, we can cancel out of there, jump back to TextWrangler, paste and if you are using a hex code, you have to put a little number sign or hash symbol in front. Don't forget the semicolon. I can't tell you how many times I have forgotten to do that. And then choose Save. If you forget the semicolon, it just ignores what you just typed. And come back to Safari and refresh. So that's how you can make like a little floating box with text inside it or of course if you are just floating an image, you don't need to put in any of this border kind of stuff.
You just need a width and you need a float: left and some sort of margin. And it's as simple as that.
- Understanding ebooks and ebook publishing
- Examining the EPUB format
- Creating linked navigational TOCs
- Formatting with paragraph, character, and object styles
- Optimizing graphics for the EPUB and Kindle formats
- Streamlining production with free InDesign scripts and plug-ins
- Creating drop caps, pull quotes, and text wraps in the EPUB
- Reviewing best practices for book cover images
- Using cross-platform EPUB editors and utilities
- Validating EPUBs
- Proofing ebooks in iBooks, the Kindle, and the B&N Nook
- Acquiring an ISBN for ebooks
- Distributing ebooks with resellers and aggregators
Skill Level Intermediate
Q: There is a problem with preptext.jsx mentioned in this course in the Chapter 4 movie named "Applying paragraph and character styles". Is there a fix or does Anne-Marie address this somewhere?
A: Please refer to the post on Anne-Marie's web site regarding this issue, which can be found at http://indesignsecrets.com/perfectpreptext-a-smart-way-to-style-local-formatting.php.