As I wrote about back in march I was wishing for inline text boxes. Boxes flowing with the text, that also should be able to "break" across text columns etc.

To fulfill my wish I wrote a small script, creating a more flexible workaround. Other workarounds was also mentioned in the old article, but this is an automated alternative to another manual approach, drawing a frame behind the given text.

An example of the automatic result.

An example of the automatic result

How the frame is supposed to look is defined by an object style, but furthermore it allows you to add a padding around the the box, so you are not limited by the text frame the text is in.

To make sure the frame is placed behind the text, they are all put in their own layer.

The layer palette with the required layer.

The layer palette with the required layer

The script also allows you to have more than one kind of box texts, you just have to set up your document correctly. For it to work it will need the following:

  • A layer with the name "Boxes" placed lower than the text
  • For each text box style, an object style named like "Box: Blue boxes"
  • A paragraph style with the same name as the object style, but without the "Box: " prefix

For an example of this setup, please download the sample document from this page.

Paragraphs and object styles.

Paragraphs and object styles

The object style you define are applied to the boxes, this allows you to define e.g. fill color, transparency, strokes etc.

To add a padding to the box, define an inset spacing in the the object styles Text Frame General OptionsCrop Amount in Frame Fitting Options.

Defining the padding as Crop Amount

Defining the padding as Inset Spacing

When you run the script, the boxes will be added behind all the text marked up with one of your box text paragraph styles, but please note that they will not "follow" the text as you type. Don't worry though, you can always run the script again, and it will rearrange the boxes.

The script

The JavaScript can be downloaded here: automatic_text_boxes_1.1.zip.

You can add it to your Scripts palette and run it from there. To do that, place the file inside the "~/Library/Preferences/Adobe InDesign/Version 6.0/Scripts/Scripts Panel" folder.

Changelog

1.1: Added support for "negative padding" - making the boxes smaller than the width of the column.

Often, in the books we do, we have to separate some text from the main flow, but still keeping it in the flow. This could be facts, side stories – what I usually would call box texts.

In a design, there are many ways to separate special text from the main text. If the book is set with a serif typeface, you could do the special text with a sans, or you could change the color of the text etc. But many times you want to put the text in a box, so you can change the background color behind the text, or you can make a border around it.

The way I currently do it, is I am placing the text in a table with one row and one column. This way I can control the background color, border, padding and distance to the text before and after the table. But the weak point of this solution, is that you cannot "break a table" across a page or column. If the table is to high to fit, it will just be placed in the next column. This leaves you to split the table manually in two rows, where the table should break.

Another way to "fake a box look" by adding a background color, is to use the paragraphs underline, strikethrough, or rule above and below functions. The way you do it, is by defining a rule or line that is about as thick as the leading and adjust its offset to match the wished effect.

An example of the three mentioned ways of adding "inline boxes" in a text flow.

Inline box != table or text frame

Using tables you can make the box have a border. Using underlines or strikethroughs, you can make the box break automatically after columns, but the background color will be only as wide as the single lines. Using paragraph rules, your box may not be more than two text lines, since the rules only applies to the first and last line of the paragraph, but it also gives you the ability to adjust a horizontal offset for the background that extends the text frame they are in.

Some might suggest you use inline text frames, but as with images they only wrap text below them. So if you wish to use text frames, to e.g. round the corners, add a shadow etc. you will be best off by putting that frame inside a table, because tables always wrap text both above and below.

So Adobe, my wish: Let us have a background color and border option for paragraphs, or add a new form of inline box.