GREP incorrectly shifting italics over in found text
Learn / Forums / General InDesign Topics / GREP incorrectly shifting italics over in found text
Tagged: GREP italics
- This topic has 9 replies, 4 voices, and was last updated 8 years, 5 months ago by David Blatner.
-
AuthorPosts
-
-
September 1, 2015 at 1:13 pm #77778Matt MayerchakParticipant
I’m working on an art book in CC2014, and the captions come in embedded into the text like the following example: (I’m using <ital> to show italics because I don’t know how to get them to show in this message)
[FIGURE 9: Shorty Lungkarta Tjungurrayi, <ital>Children’s Water Dreaming (Version 2)<ital>, 1972. Synthetic polymer paint on composition board. Cat. TK.]
The art title is in italics, styled with an italic character style.
I’m trying to use GREP to apply the paragraph style for captions, remove the brackets and the word FIGURE, and add a tab instead of the colon and space. So, it should come out like this: (the <tab> would be a tab character)
9<tab>Shorty Lungkarta Tjungurrayi, <ital>Children’s Water Dreaming (Version 2)<ital>, 1972. Synthetic polymer paint on composition board. Cat. TK.
My GREP find/change looks like this:
Find What: ^\[FIGURE (\d+): (.+)\]
Change to: $1\t$2But when I run the find/change, the italic character style gets shifted over by several characters, so it looks like this:
9<tab>Shorty Lungkarta Tjungurrayi, Children’s <ital>Water Dreaming (Version 2), 1972. Syn<ital>thetic polymer paint on composition board. Cat. TK.The italics are shifted over by several characters. I think it’s not always the same # of characters; but rather the # of characters in the first word of the italicized phrase.
I have tried lots of different configurations of the GREP search; they all work the same way. I’ve tried having it not apply the paragraph style at the same time. I even turned off the character style and had the italics styled as a local override, and ran the GREP and it malfunctioned the same way.
Does anyone have any idea why this is happening and how to prevent it?
-
September 1, 2015 at 3:04 pm #77788David BlatnerKeymaster
Yes, when you move text around with grep, it moves it independently of the formatting. It’s like it goes under the hood, changes the text, and then puts the formatting back on again in the same place it was originally. In general GREP find/change is best done on unformatted text.
-
September 1, 2015 at 3:33 pm #77789Matt MayerchakParticipant
Wow – it’s a) weird that I’ve never encountered this before, because I use GREP to move text around routinely, and b) amazing that you knew that.
You MUST have a mind palace . . . and I assume one room is dedicated just to pi
-
September 2, 2015 at 12:23 pm #77839Chris CourtMember
If you use a nested style (or GREP style, for that matter) rather than using a manual override to apply the italic character style, then it will solve your issue.
C
-
September 2, 2015 at 12:30 pm #77841Matt MayerchakParticipant
Chris,
Sorry, but that doesn’t sound right. How would you use nested styles or grep styles to apply the character style for any italics that come in from the manuscript? They’re not always in the same position, or any particular set of characters. It’s the title of an artwork, whatever that happens to be and wherever it happens to land in the entry.
I already use character styles rather than manual overrides.
I should point out that this was on a job that the client required being done in InDesign CS5. I should test it in CC and see if the problem still happens in an up-to-date version.
-
September 2, 2015 at 4:08 pm #77845Chris CourtMember
If you’re using a GREP find/replace to make changes to the captions, then I assume they must share a similar form?
In the example you gave, a Nested style like this should do the trick:
Style CAPTION_REG through 1 ,
Style CAPTION_ITAL up to 1 ,
Style CAPTION_REG through end nested style characterOf course, I’m not sure what you have named your styles, but you get the idea… apply regular caption char. style until the first comma, italic caption char. style until the next comma, then regular caption char. style until the end of the caption.
Apologies if I’m missing something.
C
-
September 2, 2015 at 6:48 pm #77846Matt MayerchakParticipant
Chris,
Thanks for the idea. Unfortunately, the text is not quite regular enough for nested styles to work. Some art titles have commas as part of them, and they are all different lengths, etc. But I do appreciate you taking the time!
I was mostly posting to point out the unreliable behavior of the GREP find/change, to see if that error in replacing the styled text was a known problem, because this is the kind of find/change I need to do frequently.
For me, learning that the applied character style is not captured as part of the found text was news, and worth noting for future reference.
-
September 5, 2015 at 6:32 am #77898Peter KahrelParticipant
Matt,
InDesign formatting points to text ranges. When you change the text using Text or Grep changes, the text is changed but the format pointers aren’t updated. In your case you can get around this problem as follows:
1. Find what: ^\[FIGURE \d+:\s+
Change to: \t
Change format: the caption paragraph style2. Find what: \]$
Find format: the caption style
Change to: <nothing>
Change format: <nothing>Note that the italics have to be in a character style because applying a paragraph style using find/change nukes local formatting.
Peter
-
-
September 5, 2015 at 6:40 am #77900Peter KahrelParticipant
(subscribing)
-
October 23, 2015 at 9:01 am #78954David BlatnerKeymaster
Matt, I just realized that Peter K’s article on page 48 of InDesign Magazine issue 76 also explains a good solution… convert all formatting to tags in the text, then run grep, then reverse, setting the tags back to formatting. Wow! (This would be a good thing to set up with findchangebylist or MultiFindChange by automatication)
-
-
AuthorPosts
- You must be logged in to reply to this topic.