Skip to main content
rubikluk8
Participating Frequently
April 3, 2017
Answered

Poetry book text formatting

  • April 3, 2017
  • 2 replies
  • 5160 views

I'm currently working on a poetry book layout and I came up with this struggle:

I have some long lines that don't fit in a single line and (without changing paragraph) and I'd like to have all of those extra lines automatically being right justified.

I tried using nested line style, but I only manage to apply a different Character Style (not a paragraph one) on the second line.

Is there a way to achieve what I need without having to manually format every "exceeding line"?

To say it in other words I need to have all lines longer than the text box right justified.

I hope I was clear enough (if not sorry, english is not my mother tongue).

Correct answer Obi-wan Kenobi

I have to underline that I'm a complete newbie in scripting and grep styles...

I tried to do the apple script that rob day​ suggested me and it seems to work.

I also tried vinny38​ grep expression but with no luck (and being a noob I have no idea why).

Obi-wan Kenobi​ grep is almost perfect but it has a little problem: it puts the "[" sign before the first line instead to put it before the second one...

Am I missing something?

Can I ask you some link for a poor noob to learn how Grep styles expressions work?

Thanks in advance...


It works fine for me! [ Tested before I post it!  ]

What I didn't say [obvious for me!] is that you need to include 2 "Nested line styles" in your para style to make this regex work! 

Try this:

/*

    0138_Poetry2Lines_MichelAllio.jsx

    Script written by Michel Allio [2017/04/03]

    See: https://forums.adobe.com/thread/2298581 [ Poetry book text formatting ]

*/

app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.ENTIRE_SCRIPT, "Poetry 2 Lines! …");

function main()    

    {

        var myStories = app.activeDocument.stories.everyItem().getElements(),

        S = myStories.length;

        while (S--) {          

            var myParas = myStories.paragraphs.everyItem().getElements(),

            P = myParas.length;

            while (P--) if ( myParas

.appliedParagraphStyle.name == "myPStyle" && myParas

.lines.length > 1 ) myParas

.lines[1].contents = "\u0008\u0008\[ " + myParas

.lines[1].contents;

        }

    }

Just change myPStyle by your para style name!

(^/)

2 replies

Jongware
Community Expert
Community Expert
April 3, 2017

Are the full lines fully justified? If so (or it isn't but you don't mind), then you can set the global paragraph alignment to "Right Justify". It's kind of an awkward name, but it will do what you want: justify all full lines, and put the last line on the right side (the default, for regular text, is to the left).

Lines that wrap to a second line are justified, and only single lines that are very nearly full width are justified as well.

Give it a try and see if you can spot the difference.

rubikluk8
rubikluk8Author
Participating Frequently
April 3, 2017

The full text is left justified.

The option you suggest is not what I'm looking for, because, being a poetry book a lot of lines are short and they have to be left justified.

It's only a minority of them that, only when they exceed the textframe, they need to be right justified...

See attached picture as reference.

Steve Werner
Community Expert
Community Expert
April 3, 2017

It couldn't be done using the InDesign interface. It might be done using either GREP or scripting. However, since I'm not fluent in either, I'll leave it to those experts to reply.

Legend
April 3, 2017

Is there an way to estimate roughly how much characters a line/width fits? Some fonts have same space for every char, but I guess thats not poetry rather than code

rubikluk8
rubikluk8Author
Participating Frequently
April 3, 2017

I'm not using a monospaced font, but approximately every line is about 50 characters (it can be 48 or 55, depending on punctuation...)