: Indent paragraph to end of the last line of previous paragraph I believe I've seen this method of indenting in older books at times and in poetry when one metered line is split between characters
I believe I've seen this method of indenting in older books at times and in poetry when one metered line is split between characters or quotes. Essentially, I'm wanting to indent a paragraph based on when the last line of the previous paragraph ends. Something like this:
I could do it manually like I have in the pic, but that's not feasible for large amounts of text. I could also do it with an indent-to-here character and a soft return, but that doesn't leave me with true paragraphs.
Any thoughts? I'm in Indesign CS6.
More posts by @Barnes313
1 Comments
Sorted by latest first Latest Oldest Best
I'm pretty sure there is no built-in method in InDesign to achieve what you want, however, your problem can be solved with a little script:
#target InDesign
var defaultIndent = 0;
//Checks if a text frame with 2 or more paragraphs was selected.
if (app.selection.length < 1 || !(app.selection[0].parentStory.paragraphs.length > 1)) {
alert("ErrornSelect a text frame with at least 2 paragraphs and try again.");
exit();
}
var story = app.selection[0].parentStory;
var paragraphs = story.paragraphs;
// loops through all paragraphs, checks the position of the last letter of the previous
// paragraph and sets the indent of the first line of the current paragraph accordingly.
for (var i = 1; i < paragraphs.length; i += 1) {
// leaves the script, if the paragraph has moved out of the last text frame in the meantime.
if(paragraphs[i].parentTextFrames.length === 0){
break;
}
var prevChar = paragraphs[i - 1].characters[-2];
var leftEdge = paragraphs[i].parentTextFrames[0].geometricBounds[1];
var indentPos = prevChar.endHorizontalOffset - leftEdge;
paragraphs[i].firstLineIndent = indentPos;
// if the paragraph has moved out of the textframe it means that the first word
// does not fit in the first line and indent will be reset to the default value.
if(paragraphs[i].parentTextFrames.length === 0){
paragraphs[i].firstLineIndent = defaultIndent;
}
};
Save this as a .jsx file into your Scripts folder, select a text frame and run the script from your Script panel via double click.
Since you did not state what is supposed to happen, if the first word of the new paragraph would not fit into the first line, I assumed it should be reset to some default value. You can set this value at the top of the script to whatever you want.
Of course, this script should be run only when you are otherswise finished with editing the text, because every tiny edit will shift the positions again. If that happens anyway, just run the script again.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.