Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Poetry book text formatting

New Here ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

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).

Views

2.1K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 03, 2017 Apr 03, 2017
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()         {       ...

Likes

Translate

Translate
Adobe Community Professional ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

Ehm, my first attemp/question – dead end.

But a script could do:

Find out which paragraph exceeds the textframe. Scripters can tell you, if theres a value for this, or if you have to find out the hard way: Compare first characters baseline y with the last character baseline y. If they differs, your line exceeds the textframe – now the script could apply another paragraph style for the right alignment.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

DBLjan

Now it seems I need a helping hand from a scripter...

I never tried to script, I have no idea where to start...

Suggestions?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

If you don't get a reply here, post in the InDesign Scripting forum here:

InDesign Scripting

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

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

It should be easy to script. This AppleScript (OSX only) right justifies any paragraph in the selected text with more than two lines.

------------------------

tell application "Adobe InDesign CC 2014"

    set p to object reference of every paragraph of selection

    repeat with x in p

        if (count of lines in x) is greater than 1 then

            set justification of x to right justified

        end if

    end repeat

end tell

So it does this:

Screen Shot 2017-04-03 at 8.03.57 AM.png

You could also consider a negative first line to left indent, which wouldn't need a script. Something like this:

Screen Shot 2017-04-03 at 7.58.09 AM.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

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.

IMG_8608.JPG

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

Poetry means one line per worm, so one para!

If a worm has too much chars for one line, we'll have 2 lines!

So, as no hyphenation, a script could compare the baselines of the first char/last char!

If different, it could catch the first first char of the 2nd line and add 2 right indent tabs + a bracket + a space!

Simple as The Force playing with Javacript! 

(^/)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

I like the translation of "Vers" to "Worms"...

Maybe Verse would be more appropriate ^^

Anyhow, I think this is a very interesting question...and I'm looking forward to see you coming up with a great script. Piece of cake for you, cher Obiwan ^^

I was wondering if it couldn't be achieved by a GREP query catching the extra words after a given number of characters (lets say 50)

Something like (?<=^.{50,51}\w+\b)\s\w+

But I can't make it work

I fully understand this would not be as clean and accurate than a script, but for my personal information, I'd love to understand why this query fails to catch anything...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

Hi Vincent! I'm a great fan of Dune! It remembers me Tatooine! 

(^/)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

Use \K

(^/)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

Ah cool! I didn't know that one...

Unfortunately, Grep query applies "right" paragraph style to both $1 and $2

Hopefully one day, I'll stop being a Padawan...

grep.gif

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

Well! Tested on "Les Fables de La Fontaine", 1 click with Grep!

Capture d’écran 2017-04-03 à 17.23.41.png

(^/)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

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...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

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!

(^/)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

Exactly what I needed. Thanks a lot.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

LATEST

Hi!

Could you update it? It doesn't work for now and script running shows error message. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines