Copy link to clipboard
Copied
Hello all,
In InDesign CS6 I'm dealing with a bunch of listings for a directory. Each listing requires multiple styles and I'm wondering what GREP code might be used, if possible, to get the job done.
An example listing reads as follows:
NAME OF COMPANY
Company address
Company contact info
Company phone number
Booth(s): 2129
Description of company.
This is how the final should appear:
I've already created the desired character styles.
I need to format the name of the company, which sometimes continues onto the second line,
and I need to format each line that starts with "Booth(s):...", which is followed by a sequence of numbers.
The rest can be styled as body copy.
Any advice on how to get this done? Thanks a lot!!
By the looks of it the company name is in all capitals. Are those caps real or is it lower case with AllCaps applied? If they're real capitals they're easy to find: ^\u\u+?$. If not, maybe the company name is the paragraph with two returns before it, which you find using
(?<=\r\r).+?$
The booths are easy to find: (?<=\n)Booth.+?\d$
P.
Copy link to clipboard
Copied
By the looks of it the company name is in all capitals. Are those caps real or is it lower case with AllCaps applied? If they're real capitals they're easy to find: ^\u\u+?$. If not, maybe the company name is the paragraph with two returns before it, which you find using
(?<=\r\r).+?$
The booths are easy to find: (?<=\n)Booth.+?\d$
P.
Copy link to clipboard
Copied
Everything worked no problem! Thanks so much for the help.
Cheers!
Copy link to clipboard
Copied
Hi Peter,
Strange Grep behavior!
I don't find a Grep style code to format "Name of company" followed by a \n and, using a F/R, I can't catch the first one!
F/R: \r\K^.+\n
"Name of company" could be: "Adobe", "Apple", "IBM", "The GREP Company", … and I don't use a double \r.
Of course, one single para style!
(^/)
Copy link to clipboard
Copied
Hi Obi-wan,
GREP styles cannot look outside of the bounds of a single paragraph.
So if a paragraph return \r is preceding some text one cannot catch this with a GREP style e.g. using a positive lookbehind with \r . With GREP Find/Replace you can.
What we should find with a GREP style is some text at the beginning of a paragraph until the first \n is reached.
So the answer for a GREP style expression catching "Name of Company" simply is:
^.+(?=\n)
Regards,
Uwe
Copy link to clipboard
Copied
Because there are other lines following with \n before the last line of the paragraph is reached, one has to do something about this. Here my solution for the whole thing as presented by the OP using three GREP styles:
The "Regular-Black-Normal" character style is masking the formatting of ^.+(?=\n) after the first found \n .
Maybe there is a better way… ?
Regards,
Uwe
Copy link to clipboard
Copied
Uwe,
A blank line is not the best way to make a space before!
… and here, not really easy!
I avoid addition of char styles via grep styles! Risky by experience, except if the grep style add something [e.g. bold, then superscript].
In fact, imho, to play it, we could need 4 grep styles!
But your way could be totally relevant for the op!
(^/)
Copy link to clipboard
Copied
Hi Obi-wan,
I indeed noticed the double returns in the example by the OP.
Yes, I could make some adjustments to two of my three used character styles with the GREP styles to distance one directory entry from the next one by using different leading values. Don't think four styles are needed.
But you are right: Using a GREP style to counter another one with formatting could backfire.
Oh, and thank you to pointing me to this other thread in the InDesign forum.
Interesting read.
Regards,
Uwe
Copy link to clipboard
Copied
Just finish my comments in the other topic!
Good reading and see you soon!
(^/)
Copy link to clipboard
Copied
Hi together,
finally with a lot of help from Obi-wan we can present a better way using three GREP styles.
1. For the first line holding the Company name:
NameOfCompany-Cap-Red
(?<!\n)^.+(?<=\n)
2. Another one on the first character in the line holding the Company name:
24pt leading
(?<!\n)^.(?=.+\n)
3. For the booth information:
Bold
(?<=\n)Booth\[s\]:.+$
Here an example of formatting using two GREP styles only where the formatting of the Company name will fail if the name is more than on line long and another example with the three GREP styles from above showing the desired formatting, but one has to watch out, that the long discription of the company will not contain any soft returns:
For some details on Obi-wan's thinking and interim exposed errors (typos on my side) see this thread:
Regards,
Uwe
Copy link to clipboard
Copied
Thanks Uwe! It was cool!
Maybe it could be useful for users to explain them how nested styles really work and can be amazing, when they can be clearly used instead of grep styles … and why they can't be played here! …
(^/)
Copy link to clipboard
Copied
Hi Uwe,
I agree with you about the target of a grep style, limited to a para (what I said!).
… But, alas, it's not so simple to find "Name of Company" followed by a soft return at the beginning of a para with:
^.+(?=\n) or ^.+\n
In fact, you can't! …
But the good news is that these 2 codes work perfectly! their behavior is in fact different ofwhat you think!
In another topic I've created [to not parasite this one], I'm finally going to explain how I format a similar situation (maybe a little more complex] just playing with a single para style and 4 grep styles!
see: With a single para style! …
The main object of this topic was to identify why the code above doesn't work in a context of soft-return(s)
I explain this point at post#6.
(^/)