Copy link to clipboard
Copied
How do you underline a textbox (NOT the text itself) like the image below? If this isn't possible, could this be done via a script? Thank you!
Use Paragraph Shading and a Paragraph rule adjusting the stroke so it only appears at the bottom (not the sidea and the top), set it as a Paragraph style.
There are a few ways to do this.
Here's just one: You could do it very easily as Text Paragraph Style, where you set Paragraph Shading and Paragraph Border, like so:
 
 
You could use a one-cell table with a border on the bottom.
With so many solutions some ordering is useful. But first, here's yet another solution, namely, Typefi's Autofit plug-in (which is free):
https://www.typefi.com/autofit/
The solutions here are of two different types:
1. If the text frame is always the same height and there's always a single one-line paragraph, then using paragraph borders or paragraph rules are the most straightforward (Derek, Brad)
2. If the text frame's height is variable (because of variable content length), then the most
...Copy link to clipboard
Copied
Use Paragraph Shading and a Paragraph rule adjusting the stroke so it only appears at the bottom (not the sidea and the top), set it as a Paragraph style.
Copy link to clipboard
Copied
There are a few ways to do this.
Here's just one: You could do it very easily as Text Paragraph Style, where you set Paragraph Shading and Paragraph Border, like so:
 
 
Copy link to clipboard
Copied
You could use a one-cell table with a border on the bottom.
Copy link to clipboard
Copied
How do you underline a textbox (NOT the text itself) like the image below?
The only way to add the stroke to one side of the frame (and not the text or a cell) is to use a hard drop shadow. This technique adds the stroke to the frame, and you can save it as an object style and reuse it.
https://www.rockymountaintraining.com/adobe-indesign-add-a-stroke-to-one-side-of-a-frame/
~Barb
Copy link to clipboard
Copied
This is the right solution for a separate text frame. If the element is meant to be a heading or other running/text flow element, styles that apply to the text and not a separate frame would be more... organic. A combination of text shading and a bottom border would achieve the effect without separating the item from the text flow.
If the OP really means "text box," though, this, and an Object Style, are the simple solution.
Copy link to clipboard
Copied
Hi @Barb Binder -- Very nice solution. Only I get a thin grey line around the whole box. Any idea how I can get rid of it?
Copy link to clipboard
Copied
Ugh! You are absolutely right, @Peter Kahrel. This was an effect I was working through with a client. They wanted a rule around the outside (which effectively hid the overflow issue) but even that likely wouldn't have worked in print. Inspired by your magnification, I checked the top/bottom edges and there's a slight blend.
We went in a different direction for the frames and I didn't write this up until a few months later (and left the stroke off) and the rest is obvious! Thanks for pointing it out.
~Barb
Copy link to clipboard
Copied
This is getting ridiculous, but I can't help it: I'll add *another* way to do this. Draw a line, cut it and paste it into the text, set the anchored object options something like this:
And save as an Object Style (very important!). The cons of this approach are (1) anchored objects can be fiddly if you aren't used to them (eg. you may accidentally delete the rule while editing text if you forgot it was there), and (2) changing the width of the frame will not change the width of the line—you have to do that manually, or via the object style.
Even having read all the great answers here, there are still some cases where I would do it this way.
- Mark
Copy link to clipboard
Copied
Thank you everyone! So many ways to do this. I've learned a lot! Appreciate all of your help!
Copy link to clipboard
Copied
This gives me a line all the way around a text box. What am I missing?
Copy link to clipboard
Copied
Was this directed to me, James? Probably, but I saw Peter's question first this morning, so addressed it up there.
~Barb
Copy link to clipboard
Copied
No, I was trying @m1b 's approach and reapplying the style gives a line all the way around the box. I'll look at your answer to see if it addresses my issues.
I am finding the text-frame solutions a bit complicated given that a simpler, 'auto adjusting, automatic and inline' paragraph style accomplishes the same function. 🙂
Copy link to clipboard
Copied
Ah, @James Gifford—NitroPress, I assumed it was for Barb's technique too. In my approach, the object style is configured for, and applied to, the anchored Graphic Line, not the frame. The object style handles the anchored object options as well as the styling for the line, and possibly the width of the line.
- Mark
Copy link to clipboard
Copied
You need to anchor extra Graphic Line in the text.
Copy link to clipboard
Copied
With so many solutions some ordering is useful. But first, here's yet another solution, namely, Typefi's Autofit plug-in (which is free):
https://www.typefi.com/autofit/
The solutions here are of two different types:
1. If the text frame is always the same height and there's always a single one-line paragraph, then using paragraph borders or paragraph rules are the most straightforward (Derek, Brad)
2. If the text frame's height is variable (because of variable content length), then the most convenient approach is a single-cell table (Eugene) or a scripted solution (Mark)
Typefi's Autofit solution is in category 2: you can set a relationship between a graphic line (or lines) and a text frame such that when the text frame is moved or resixed, the line travels/sizes with it. A bit like Mark's scripted solution but without the downsides.
Copy link to clipboard
Copied
I disagree on point 1. Using paragraph shading and bottom border (not rule), I am able to create a single paragraph style that seems to meet all the demands of the OP, all the details suggested by others... and is perfectly adaptable to single line, multi-line and even multi-paragraph content:
Unless the requirement that this apply to a text frame is mandatory, the paragraph-style method is simpler and requires no juggling of object styles or manual adjustment of line length etc. (And even if a text frame is thought mandatory, I believe this option has the advantage of keeping the content in a single text flow, almost always an advantage for flowing layout, accessiblity, export, etc.)
As always... am I missing something here that dictates the rather complex solutions instead?
Copy link to clipboard
Copied
By the way, Peter, my solution was a simple anchored graphic line—no scripting required! For once, haha!
- Mark
Copy link to clipboard
Copied
Well, the OP's request is in fact ambiguous. Her example suggests the simple case of a single one-line paragraph, which is easy to handle with a paragraph border. But at the same time she asked for underlining the text box, which some of us (including me) interpreted as 'how do you stroke only the bottom of a text frame'. That is, if text changes affect the height of the frame, the stroke stays on the bottom of the text frame. With paragraph borders you won't be able to achieve that I don't think.
Copy link to clipboard
Copied
The paragraph style maintains the box proportions and underline perfectly regardless of the content — that's been my point here, that the flexibility of the style has been overlooked or misunderstood.
This is one paragraph style, unchanged across the examples:
...and so on. All paragraph side spacing can be adjusted to limit box width if needed. The only limitation is that space above and below may need to be controlled by the adjacent paragraphs if reasonable inter-paragraph spacing in the box is desired. (if the spacing is wide enough to distance the box from other text, it's rather wide inside the box, and vice versa. It can be done, but not with fine gradations.)
But all of that is accomplished with no more than a Paragraph Shading and Paragraph Border (bottom only) setup —
— and is completely flexible and self-adjusting.
Copy link to clipboard
Copied
I think we'd all agree that the remaining answers are all correct and applicable, depending on the circumstances. I've used every one at different times (except the plug-in Peter, thanks for that).
- Mark