How to Add a Rule Around a Paragraph
At the InDesign Conference in Denver, I showed attendees how to add an automatic rule around a paragraph using an admittedly strange, but effective technique. The details are pretty non-obvious, so I promised this detailed follow-up post.
It is a multi-step procedure to set up this trick, but once you’ve created it and saved it in a paragraph style, it is effortless to use.
For this example, I’m going to create a 2-point black rule around a paragraph. But this technique works with rules of any weight and color.
Using Paragraph Rules and Shading to Add a Box Around a Paragraph
1. Create a paragraph style named “Body text, boxed” that has paragraph rules above and below. Use Left Indent, Right Indent, Space Before, and Space After to “inset” the paragraph text away from where the rules are going to be.
2. Measure the width of your column. My column is 225 points wide.
3. Divide the weight of your rule by the width of your column, and multiply by 100. So in my case: 2 / 225 * 100 = .89
4. Choose New Gradient Swatch from the Swatches Panel menu
5. Create a new linear gradient swatch called “Rules” that has 6 “stops” on the Gradient Ramp. To create a new gradient stop, just click below the gradient ramp. These stops, from left to right, should be black, black, white, white, black, black (or substitute your stroke color for black, and whatever color you want for the box background for white). The location of the gradient stops is not important at this point, only the order from left to right.
6. Now, working from left to right, select the first gradient stop, and enter 0% for the location
7. Select the second gradient stop, and enter your value from step 3 (.89 in my case)
8. Select the third gradient stop, and enter the value from step 3 for this stop also
9.Select the sixth gradient stop (the one furthest to the right, and enter 100% for the location
10. Select the fifth gradient stop and enter (100 – your value from step 3) (99.11 in my case)
11. Repeat for the fourth gradient stop
12. Click the OK button. So now we have a gradient that goes from black to black, and then goes immediately to white with no transition, and then returns to black the same way.
13. Edit your “Body text, boxed” paragraph style to use the “Rules” gradient swatch for the Paragraph Shading color. You will probably need to adjust the Top and Bottom Offsets so that the vertical rules line up with the rule above and rule below.
Of course, the whole point of this is that now you have a paragraph style that can be applied to paragraphs of any length, and they will be boxed automatically. The box will grow and shrink as the paragraph is edited.
I’ve noticed that at as I zoom in and out that sometimes the right side rule appears slightly thinner than the left side rule. But this seems to just be a display issue. If I zoom all the way in on a corner of the box, the rule weights match perfectly.
In terms of output, the effect will look great in print, PDF, or Fixed-Layout EPUB. But don’t use it for a reflowable EPUB unless you’re OK with rasterizing the entire text frame to preserve its appearance. Also note that if you resize the width of the column, you’ll need to go back and recalculate the position of the gradient stops, and edit the gradient swatch accordingly.