Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

using GREP style for format table of contents

Return to Member Forum

  • Author
    Posts
    • #65169
      Elaine
      Member

      I want to use GREP style to format a table of contents. I want to bold chapter titles, like:

      Chapter 1 and so on.

      However, some chapter titles will be followed by a “—” and “two words”.

      How can I do this? Thanks in advance. I hope I explained clear enough.

    • #65173
      David Blatner
      Keymaster

      is this text in the middle of a paragraph? Or at the beginning of the paragraph, like in a TOC?

      You might be able to use this code:
      Chapter \d+? ?~_ ?\w+? \w+?

      But will it always have two words? GREP only works with very specific patterns.

    • #65175
      Elaine
      Member

      The beginning of a paragraph.

      That worked for the chapter title with the “—” and “two words” but not the others.

    • #65177
      David Blatner
      Keymaster

      Can you provide more information? What did it not catch?

      As I said, GREP has to find a very precise pattern. So, for example there is no way for GREP to find both of these: “In Chapter 1 — Tools you will learn about the tools but in Chapter 2 — Use and Practice you will learn about other stuff.”

      It can’t do it because there is one word in the title in the first chapter title and three words in the next. How could InDesign/GREP possibly know what is a chapter title and what isn’t in these cases?

    • #65179
      Elaine
      Member

      It didn’t catch

      Chapter “1” and so on. Maybe I’m going about this the wrong way. I know GREP can look for specific words but what if it’s a specific word followed by a number? Would that work or would it all have to be in the same paragraph?

    • #65254
      Justin Sligh
      Member

      Elaine,

      Could you provide us with a brief list of chapter titles and describe again what you would like to have formatted?

    • #65257
      Elaine
      Member

      okay, the chapter titles look like this:

      Chapter 1
      Chapter 2
      Chapter 3
      Chapter 4
      Chapter 5
      Chapter 6
      Chapter 7
      Chapter 8
      Chapter 9

      “Chapter” is the same and there’s a number after each heading. Is there a GREP style (to make the chapter and number bold) I can use for this?

    • #65258
      David Blatner
      Keymaster

      I think there is a basic misunderstanding here. If you are just trying to make the word Chapter and the number bold (or whatever different style), then you should probably just set it up with a Nested Style, not a Grep Style. Nested Styles are good for things like “from the beginning of the paragraph to…” and they’re way easier to create. Do a search for Nested Styles to learn more.

      Also, at the beginning of this thread you said you wanted it to apply to the word chapter, then the number, then a dash, then the title of the chapter. That’s why it was so tricky. If you just want to search for “Chapter X” (where X is a number, you could use the grep: Chapter \d+? which searches for the word Chapter followed by a space followed by one or more numbers.

    • #65259
      David Blatner
      Keymaster

      I think there is a basic misunderstanding here. If you are just trying to make the word Chapter and the number bold (or whatever different style), then you should probably just set it up with a Nested Style, not a Grep Style. Nested Styles are good for things like “from the beginning of the paragraph to…” and they’re way easier to create. Do a search for Nested Styles to learn more.

      Also, at the beginning of this thread you said you wanted it to apply to the word chapter, then the number, then a dash, then the title of the chapter. That’s why it was so tricky. If you just want to search for “Chapter X” (where X is a number, you could use the grep: Chapter \d+? which searches for the word Chapter followed by a space followed by one or more numbers.

    • #65260
      Elaine
      Member

      Thanks for your advice. I tried the simple grep you posted and it worked.

    • #65261
      David Blatner
      Keymaster
Viewing 10 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads