See the underline continues after each word before a line-break? How can I automatically remove that underlined whitespace?
2 Answers
It's an issue, but there's nothing automated you can do.
I've filed several bug reports for InDesign and Illustrator about using spaces for centering, underlines, etc. and in years Adobe hasn't corrected the issue.
The only thing you can do is delete the trailing space on that line or manually remove the underline from the space. There's no automated solution.
It's an issue, but it can be fixed – although not automatically/unattended.
The JavaScript in the answer to the exact same question from 2009 on InDesignSecrets applies a special character style to underlined end-of-line spaces, and switches Underline off for that style. That way, you can easily restore/remove the patch when the text gets edited and you need to run the script again.
Unfortunately, posts in the forum on InDesignSecrets get quote and dash beautifications (curly quotes and en-dashes) and so the script is not ready-to-copy. Here it is with fixes:
//DESCRIPTION: Begone, Ugly End Of Line Underlining!
// (c) Jongware 16-Dec-2009
var blankStyle = app.activeDocument.characterStyles.item("NoUnderline");
try { blankStyle.index; } catch(_)
{
blankStyle = undefined;
}
if (blankStyle == undefined)
{
blankStyle = app.activeDocument.characterStyles.add();
blankStyle.name = "NoUnderline";
blankStyle.underline = false;
} else
{
blankStyle.underline = false;
}
for (a=0; a<app.selection[0].lines.length; a++)
{
if (app.selection[0].lines[a].characters.item(-1).contents == " ")
app.selection[0].lines[a].characters.item(-1).appliedCharacterStyle = blankStyle;
}