4

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:

enter image description here

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.

  • 1
    Indent-to-here would not work, it would indent all next lines. – usr2564301 Nov 7 '15 at 20:42
6

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("Error\nSelect 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.

  • Great solution. Has a few limitations, namely that it applies to the whole text frame and as you mentioned, doesn't reflow. But it'll work! – Ian Nov 10 '15 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.