Hi everyone,
Within each chapter of a book I’m working on, there are level 1 headings that look like the following:
¶5-100 Context
So each of these headings has a paragraph number, ie. ¶5-100 and then the name of the heading, ie. Context. There’s a tab between the para number and the content of the heading.
I need to create a specific chapter by chapter table of contents using the content of these level 1 headings. The information will be located at the start of each chapter.
It’s easy enough to do but when the TOC is genereated I get the following effect:
¶5-100 Context [tab] page number
¶5-120 next heading [tab] page number
¶5-140 next heading [tab] page number
¶5-160 next heading [tab] page number
I don’t need the page numbers at all and instead of the above, I need the following result:
Context [tab] ¶5-100
next heading [tab] ¶5-120
next heading [tab] ¶5-140
next heading [tab] ¶5-160
Once I have the above effect, I would then go ahead and create cross references where the para numbers within the TOC are the source of the Xref and the destination is the relevant heading within the body of the chapter.
So is there a way to manipulate the results so that the headings appear as the above? I know it probably can’t be done but just thought I’d ask incase I’m missing something.
Appreciate any help.
I don't think you can do it with a standard TOC by itself, but you might be able to do it with cross-references, or maybe using a standard TOC in combination with character style-based running head variables that would populate non-printing frames to be included in the TOC. That method would only work, though, for one heading per page.
Are you on the GREP tab or the Text tab of the Find/Change dialog? I often make the mistake of entering GREP queries in the text search and it takes me awhile to figure out why no match is found.
Can you post a screen cap of the un-altered TOC with hidden characters showing? Might be something at the start of the line you didn't mention. Or perhaps I misinterpreted and you really have the pilcrow there as part of the text? for that change the find to ^(~7\d+-\d+) (.+)
The forums won't let me insert an image - the insert image button is greyed out after I navigate for the file on my computer.
I'm definitely on the GREP tab. There's nothing at the start of the line. Not sure what a pilcrow is? There's that para symbol there at the start of the text if that's what you mean.
I tried your revised code but again no luck. Can you point out what the code means so maybe I can decipher why it's not working?
Thanks again
Sorry I spoke too soon. I revised your code from this:
^(~7\d+-\d+) (.+)
to this:
^(~7\d+-\d+)(.+)
ie. I removed a space and it seems to have nearly worked. The entries now look like this:
[tab] heading content [tab] ¶5-105
So it's nearly there but the result is that it's putting an extra tab before the heading content.
Is there a way to remove that?
Sorry, Looks like I didn't catch Jive changing the \s to a space when I copied the query. You want ^(~7\d+-\d+)\s(.+)
That translates to at the start of a paragraph find (a pilcrow [paragraph mark] followed by one or more digits, a hyphen,then one or more digits) any whitespace (any characters up to the end of the paragraph).
The replace is the any characters expression, a tab, and the pilcrow/digits group, and the 'any white space' is thrown away.
Could I ask another related question? I've got my TOC looking like this now:
heading content [tab] ¶5-105
How would I create a nested style so that the ¶5-105 is coloured separately from the rest of the TOC entry? I've looked into the nested styles but it only lets you target areas "up to" or "through". How can I say colour everything "after the tab"?
Appreciate any further help.
a. Use this GREP style:
(?<=\t).+
This will look for a tab, then apply a character style of your choice to the rest of the line, excluding the tab (which might be important if you apply underlining).
GREP styles are my favourite because I can express virtually everything I need with those -- they are so versatile! However:
b. Use this Nested Style:
[None] through 1 [Tab Characters]
yourStyle up to 5 [Words]
(The latter number is because I'm not sure how InDesign counts 'words'. There doesn't seem to be a "Up to End Of Line" code.)
[Jongware] wrote:
b. Use this Nested Style:
[None] through 1 [Tab Characters]
yourStyle up to 5 [Words]
(The latter number is because I'm not sure how InDesign counts 'words'. There doesn't seem to be a "Up to End Of Line" code.)
When I want to run a nested style up to the end of a paragraph in a situation like this I often just tell it to run up to an end nested character style marker and don't insert one. You can use any character that isn't encountered and the nested style will run to the end of the paragraph. In this particular case you could also "swap" the formatting and define the paragraph style the way you want the numbers to look, then apply a nested style through 1 tab to change the text ahead of it, then there's no need for a "none."
North America
Europe, Middle East and Africa
Asia Pacific