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.

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 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.

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

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.
Comments
Rich Adin wrote:
Good morning, Thomas.
Thanks for the tip. I downloaded your script and tried it. It works great except for one major limitation (major at least for me): the frame it creates is column width rather than slightly larger than text width.
For me, where this fails is when I need to have the frame behind text that is indented left and right from the column margin. For example, if a standard paragraph runs the full column width, say 144 points, but the text I need framed runs only 72 points wide and is indented 36 points on both left and right, the script creates a frame that is 144 points wide, not 72 points + x points on either side (so that the frame extends beyond the text). Perhaps there is a way around this, but I couldn't find one with the script.
Elsewise, the script works great.
Silkjaer wrote:
Rich: I'll just answer here as well as on InDesignSecrets, and rephrase a little.
What you request is quite easy, since scripting a way to find the columns position on a page is quite harder than finding out where text is. That is the way I find the ascenders and descenders location for the box.
What you really need though is perhaps not calculating where the text begins and ends - since it is not the same as the indents of a paragraph. E.g. for ragged right text, the text lines ends different places for a paragraph. So how can I fix the script?
1) Enabling "negative padding", so you can easily control the amount of negative space from the columns.
2) Enabling a box that checks for indents in the paragraph style and uses the column placement -/+ the padding for the box.
I will be delighted to release an update with the feature :)
Best,
Thomas
Rich Adin wrote:
Thomas, I left you a reply on InDesignSecrets, which I won't repeat here. But let me add this to my other response. Each paragraph style that I use has its own left and right indents. If the script could pickup those indents and +/- to them, the effect would be uniform. It isn't clear to me how "negative padding" would work. If it would let me set the frame width in the object style and have multiple object styles, each with different frame widths, that would work well.
Sorry for my confusion and for not being clear. I am not a sophisticated user of InDesign and am just now approaching 10 months of using it (for the previous 15 years I had used Ventura for typesetting and just made the move to ID with the release of CS4).
Silkjaer wrote:
Rich: As it is now, you can add a "padding" to the box to define how much you want to size the box "extra/more" than the column width.
By adding an option for working with "negative" paddings, I can allow the box to shrink from the column width. So if you have a 30pt left and right indent you would perhaps define a -25pt left and right "padding" for the boxes.
I think this is the best solution - will also look better in a design/page layout that all boxes are equally wide, and not defined by the text length (in my opinion).
Rich Adin wrote:
Thomas, the negative paddings sounds like it would work just fine. I agree it would look better if all the boxes are equally wide, and that is what I am trying to accomplish (albeit not saying it very well). I, too, do not like boxes defined by text length.
Silkjaer wrote:
Rich: I have uploaded an updated version with support for negative padding now.
Hope it suits your needs!
Rich Adin wrote:
Thanks, Thomas. I will give it a try later on in the week and let you know.
Richard Adin wrote:
Thomas, thanks. It works great.
Mary Jane Rutkowski wrote:
Hi Thomas
Thanks for the script! I'm not sure what I am doing wrong -- I cannot get the script to work. I get an error on line 67 of the script. Not too sure what this means. This occurs even when I copy your object and paragraph styles to a new document.
Silkjaer wrote:
Mary Jane: No problem! What version of InDesign are you using, and did the script work in the packaged sample file?
Mary Jane Rutkowski wrote:
Hi Thomas
Thanks for the response! I use CS4 and the script did work in the sample file.
Silkjaer wrote:
Mary: You don't by any chance have any text overflow in the document? If you don't mind, please send it to silkjaer at theundersigned dot net, and I will check it out :)
Evgeny Trefilov wrote:
My friend created a plugin, which adds boxes and frames to paragraph style (Paragraph Border). The frames are reflowed dynamically.
demo version for CS4/Mac here
http://www.beeasy.ru/pb/?id=4
Wolf Eigner wrote:
Absolutely awesome! I love this script for saving me probably hours and days of work, even though it runs just over a half hour in an 900 page text-only INDD.
Could you please add support for more than one layer, e.g. all object styles starting with “Box1: …” go to layer “Boxes1”, all “Box2: …” go to layer “Boxes2” and so on? That would be very helpful for creating “brackets”, i.e. frames where only the left and the right edge is supposed to show (and the rest is covered by a [Paper] box that is placed on a separate layer above “Boxes2”, but below “Boxes1”. :o)
Thanks a lot!
Jayamon Augustine wrote:
Do you have any InDesign CS3 version for this?
Loic wrote:
Hi Thomas,
We would like to reference your script on our website : http://www.scriptopedia.org
Do you agree ?
Regards,
Loic
Silkjaer wrote:
Loic: you are more than welcome :)
Loic wrote:
Hi Thomas,
Sorry for the delay, I checked the site for a moment and thought that maybe I will receive an email and then Time did teh same to me than to all of you, it just swooooooooooooooshhhhed.
Thanks a lot for your agreement. Your scripts are awesome and I am sure our readers will enjoy them and have a look on your website ;-)
I put you scripts in my todo list :-)
Keep up teh good work.
Loic
albastru22 wrote:
Thank you for this script.
I am using indesign cs5 and I have 2 problems: 1. A paragraph begins in a column and continue on the next one. The box for the first column is ridiculously large. (i just found a fix: I works great if I dont use full vertical justify)
Next one: I expected that every relaunch of the script will delete old boxes... Or I have to do that manually?
Write a comment!