Copy link to clipboard
Copied
I have picture captions which I want to format with a full stop in a paragraph style (I would prefer it to just be in the style, not actually typing it, as it is not to be used in e.g. the ToC).
Can this be done? In the GREP maybe (in that case how)?
By 'full stop,' I am assuming you mean 'period'? (Just clarifying; the former term isn't common in American English or outside of a typesetting shop. 🙂
But I read your query as that you want a stop/period at the end of every figure caption.... but you don't want that dot to appear in any secondary use like a TOC, list of figures, etc.?
GREP styles can't replace content, only apply format to it. This is sorta-kinda conditional text, but on the fly within the document, which can't really be d
...Hi Chris:
As per @James Gifford—NitroPress, we can't add a period/full stop to a paragraph style—just formatting
You could add it with a GREP find/change (not a GREP style) but then you'd have to remove it via second GREP find/change each time you updated the List of Figures, which can only pick up full paragraphs, punctuation included. Or again, as per @James Gifford—NitroPress, you could add a GREP style to the LOF entry to just hide the period.
To add the full stop to the captions
F
...Copy link to clipboard
Copied
By 'full stop,' I am assuming you mean 'period'? (Just clarifying; the former term isn't common in American English or outside of a typesetting shop. 🙂
But I read your query as that you want a stop/period at the end of every figure caption.... but you don't want that dot to appear in any secondary use like a TOC, list of figures, etc.?
GREP styles can't replace content, only apply format to it. This is sorta-kinda conditional text, but on the fly within the document, which can't really be done in any simple way. The only way I can think of to make this work is apply GREP styles to each secondary use (a TOC line entry style, for example) that applies a color of "None" to the terminal period/stop.
Copy link to clipboard
Copied
Many thanks! I will do what you suggest, add the period (is it the same expression used both in UK and US English?) and then hide it in my TOC.
Copy link to clipboard
Copied
Hi Chris:
As per @James Gifford—NitroPress, we can't add a period/full stop to a paragraph style—just formatting
You could add it with a GREP find/change (not a GREP style) but then you'd have to remove it via second GREP find/change each time you updated the List of Figures, which can only pick up full paragraphs, punctuation included. Or again, as per @James Gifford—NitroPress, you could add a GREP style to the LOF entry to just hide the period.
To add the full stop to the captions
Find: (.+)
Change: $1.
Paragraph style: Caption (call it anything)
Assuming all captions are one sentence, to hide it in the LOF:
Create a character style with the color set to none.
Assign the character style as a GREP style to the LOF entry
Apply style: Hide (call it anything)
To text: \.
~Barb
Copy link to clipboard
Copied
Many thanks! You read my mind - I am new to GREP so almost always need help in formulating it correctly - with your template I can fix my captions easily :).
Copy link to clipboard
Copied
Besides having your "hide" style change the color to 'None,' you might want to pile on making the period vanish by assigning it a size of 1 pt and a width of 1%. This will keep it from distorting any following spacing, such as for a tab leader.
Copy link to clipboard
Copied
Great tip, many thanks!
Copy link to clipboard
Copied
I now saw that one of the captions include periods I want to keep (e.g. when the caption is "W. Williamson". Is there a way to only select periods which occur at the end of a paragraph (no caption is longer than a single paragraph)?
Copy link to clipboard
Copied
Yes, that's what GREP is all about. It's trivial to just replace all [x] characters, but being selective is where it gets tricky.
Your GREP style for each affected TOC level/style should be something like:
That will find periods only if they are at the end of a paragraph. This can be expanded if there are any variant cases.
Copy link to clipboard
Copied
This is almost magical 🙂
I now realized that there is sometimes one or two empty spaces after the final period in the caption. I thought that something like this would address this, but doesn't seem to work: (\.$)|(\.\ $)|(\.\ \ $)
Copy link to clipboard
Copied
This is almost magical 🙂
I now realized that there is sometimes one or two empty spaces after the final period in the caption. I thought that something like this would address this, but doesn't seem to work: (\.$)|(\.\ $)|(\.\ \ $)
By @Chris201Chris
You don't have to "escape" spaces - but you should rather run this globally:
Find:
\.\s+$
Change:
\.
Of course, always test on a copy of your document.
Copy link to clipboard
Copied
GREP is a hell of a lot of fun, and even more useful, once you master the basics. You can do insanely weird things with it.
Note that most general GREP information is a bit cryptic, intended for the code crowd and running from a command line on file sets; ID's implementation is a bit specific and different. You can't do better than Peter Kahrel's GREP for InDesign as a learning resource, but here's a composite cheat sheet I recently updated. (You typically want to use a specific 'space' wildcard in searches, although a space as you've used will often work fine.)