11 Replies Latest reply on Feb 10, 2014 11:03 PM by Peter Spier

Can I create a character style to replace regular spaces with non-breaking spaces?

I'm working on a textbook with hundreds and hundreds of equations. I need to make these not break across lines. It seems to me that the easiest solution would be to create a character style that would automatically convert the regular spaces to non-breaking spaces. I would still need to select each equation and apply the style, but at least I wouldn't have to select and change each space.

Or if there's a way to do it with GREPs, I'll take that, too. Or if there's some even better and easier way to do it that I haven't even imagined, I'll take that, three. ;^)

~Valerie

• 1. Re: Can I create a character style to replace regular spaces with non-breaking spaces?

You can create a Character Style that only contains the no-break characteristic, and apply that to your equations. GREP might work, but it depends on whether there is a pattern to them. Can you show what some of them look like?

• 2. Re: Can I create a character style to replace regular spaces with non-breaking spaces?

How do I create a character style that applies only to one character? I'm not seeing that option.

~Valerie

• 3. Re: Can I create a character style to replace regular spaces with non-breaking spaces?

You can apply the no-break attribute to the whole equation - just create the character style with no-break checked.

If you post a screen shot of several of your equations, I will look tomorrow to see if there might be a GREP search that would work.

• 4. Re: Can I create a character style to replace regular spaces with non-breaking spaces?

Thanks. That gives me something solid to work with.

As for the GREP possibilities, this paragraph shows several:

I said "equations," but they're really logic propositions. Not really any set form -- some short, some long. Lotsa funky characters.

~Valerie

• 5. Re: Can I create a character style to replace regular spaces with non-breaking spaces?

I don't see how to work GREP with those, but there are lots of far more advanced GREP users than I on this board, so maybe someone else can help with that.

• 6. Re: Can I create a character style to replace regular spaces with non-breaking spaces?

How are they getting to be italics now?

• 7. Re: Can I create a character style to replace regular spaces with non-breaking spaces?

This image is of the PDF of the original document...the only file where the special characters were rendered correctly. I'm importing from the Word file, which uses some sort of equation widget that turns every proposition into an uneditable and incorrect blob, and then copying the correct bits from the PDF, and then retyping the missing characters. It's soooo much fun! ;^P

~Valerie

• 8. Re: Can I create a character style to replace regular spaces with non-breaking spaces?

Are there other italics in the file (with the same paragraph style)? If not, or if you can use a selection to limit the scope of the search, you could just look for italics and apply the character style you need, otherwise, it's going to be a bear to find a way to isolate the equations. Perhaps it could be done by including a class containing the symbols if every equation has at least one, but still it would probably depend on the text already being italic. I don't see a way, either, to define a pattern that matches all of the examples in your screen shot.

• 9. Re: Can I create a character style to replace regular spaces with non-breaking spaces?

You should use non breaking space with fixed width for that pupose at the first place. I would not recommend to use a character style here. You can find and replace at the end with a GREP to do it faster, but not with a character style here.

• 10. Re: Can I create a character style to replace regular spaces with non-breaking spaces?

Willi,

Yes, I'm definitely going to use smaller spacing, but I just don't know how to set up the GREP in this case. As Peter noted, the pattern of the propositions just isn't consistent enough. I'm wondering if multiple styles could be set up to change any space that comes before or after any of the special characters. I just don't know enough about GREPs to know where to begin.

Also, is it possible to copy GREPs between paragraph styles...of which this project has dozens (even after I deleted a bunch of extraneous ones left over from previous editions)?

~Valerie

• 11. Re: Can I create a character style to replace regular spaces with non-breaking spaces?

GREP styles can be added to any paragraph style (and I suppose you could copy the expression to the clipboard to paste into the dialog in each), but you do need to be clear on the differnce between a GREP style and using the Find/Change GREP tab. GREP Styles can only apply a character style to found text, thereby affecting the formatting of the existing text, but they cannot change the actual text itself, substituting one character for another, or adding or deleting text. That can only be done with Find/Change.

IF you only want to affect spaces on eihter side of special characters, that's relatively easy using the class notation and including all the special characters in the class, but looking at the examples I don't think that's sufficient to prevent your equations from breaking.