Fixing Over-Extended Paragraph Borders in InDesign
With the new March 2018 release of InDesign, the paragraph border feature has been improved. But an old problem remains. When a paragraph with borders breaks across a page, the borders extend beyond the page margins.
The reason for these over-extended borders is the offset setting in the Borders dialog.
In this example, we’ve told InDesign to extend the top offset by 13 points and the bottom offset by 12 points and this is reflected by those extra, unwanted border bits above and below the margins.
So to fix the over-extended border problem, just set these numbers to 0. Easy, right? Wrong! What then happens is this:
The first problem has been fixed. The borders do not extend beyond the page margins any more.
But we can’t just get rid of the offset. We need it. The top and bottom borders are now much too close to the text! This looks terrible.
The problem reminds me of a too-short blanket: Pull up and your toes poke out. Pull down and your shoulders get cold. Typographically speaking of course.
So what is the answer?
A possible answer is to add a white rectangle above the top margin and below the bottom margin to mask the extra border lines. But this is clumsy, especially since these rectangles will not travel along with the paragraph if changes are made. They also risk accidentally hiding parts of the layout.
Instead, I came up with the following solution.
InDesign’s engineers seem to have ensured that the top margin is drawn above the tallest ascender on the top line, and the bottom margin, below the deepest descender on the bottom line.
So adding a very large character on the top line pushes the margin up. Ditto for the bottom line. However, large characters take up extra width as well as extra height. So increasing the point size of a character isn’t so good. But there is another option.
Changing the “vertical scale” of a character makes it taller without making it wider. Luckily, it also pushes the borders away from the text. Bingo!
Here, then, are the steps to make sure that a paragraph’s borders do not extend beyond the page margins, but are sufficiently distance from the first and last lines of text:
- Set the top and bottom Offsets of the paragraph border to 0 (or even -2).
- Select a space character in the first line of the paragraph and apply something like 240% vertical scaling. This will push the top border away from the first line of text.
- Select a space character in the last line of the paragraph, or you could even select the final paragraph return, and apply around 460% vertical scaling (for technical reasons to do with font construction this value must be greater than the previous one). Of course both these numbers need to be adjusted to suit different layouts.
The end result is perfect:
The borders extend just the right amount (that is, they are flush with the font ascenders and descenders), and the border is nicely spaced away from the first and last lines of text.
You can tweak the offset and vertical scaling to get just the right look – don’t forget that offset values for paragraph borders can be negative as well as positive.
The beauty of this solution is that everything travels with the paragraph. No extra objects are needed to cover up the over-extended border bits. Moreover, judicious use of character styles (I mean, using two custom-made character styles to apply the vertical scaling—one for the first line, one for the last line) will ensure that (a) clearing the paragraph’s style overrides does not inadvertently mess up the borders; (b) the applied vertical scaling will not show up as a paragraph-level override, and (c) that the formatting is consistent (the standard advantage of using character styles).
Advanced: One paragraph style to rule them all!
As a final challenge, I asked myself whether these vertical scaling settings could be included as part of single paragraph style definition. We would need the paragraph style itself to target the first space on the first line of the paragraph and the last space on the last line and apply the necessary character styles. Since this is the sort of thing GREP styles do, it seemed easy.
Well, GREP styles seem to be the way to go here, but in fact there is a catch. It is surprisingly difficult to come up with an expression that targets the first space in a paragraph. (Using a nested style to target this first space is perhaps the simpler solution; but can it be done with GREP alone?)
I turned to David Blatner, and he posted the question on the excellent “Treasures of GREP” Facebook group, and the user Dhafir Foto (one of the group’s moderators) came up with an ingenious answer that works:
The details of this expression, including the purpose of the initial (?m), are beyond the scope of this article. For more information, check out the Facebook post itself.
The last space in the paragraph is also rather hard to target, but targeting the final return of a paragraph is much simpler and should work just as well (better, maybe, since the final return, unlike the last space, is guaranteed to be in the last line of paragraph). Just in case the paragraph ends not with a return character but with one of InDesign’s other end-of-paragraph markers (column breaks, frame breaks, etc.), however, it may be safer to use this expression instead, which includes all possibilities: \r|~M|~R|~P|~L|~E.
After creating the two character styles necessary to push away the border, your final paragraph style GREP-style settings should look similar to this:
So, while we wait for Adobe to add the clearly required “Keep border in frame” checkbox as part of the border options settings (it’s already there in the paragraph rules dialog, after all), at least you now have a “set and forget” workaround that gives full control of paragraph border padding even when a paragraph spans two pages.