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

GREP for Chapter Number?

Return to Member Forum

  • Author
    Posts
    • #82543
      Anonymous
      Inactive

      Good afternoon, all!

      I’m looking for some GREP advice: Every time you see “Chapter 2” make it “Chapter ‘variable—chapter number'”.

      I know that ~H is used for variable-chapter number, but I’m having difficulty with changing the hand-keyed chapter number to switch out to the defined chapter number variable. This has got to be super easy, right?

      Thanks in advance!

    • #82562
      Aaron Troia
      Participant

      Elizabeth,

      I’m not sure what GREP you’ve used so far but try

      Find: (Chapter )\d+
      Replace: $1~H

      That will find each instance of Chapter followed by a number (if you have a hard return after you could throw in a lookahead(?=\r) right after the \d+ in Find) and will reinsert Chapter and the space (from the capture group in the Find field) and replace the digit with the ~H chapter variable.

      Hopefully that works, let me know if you have any issues.

      Aaron

    • #82623
      Anonymous
      Inactive

      Thanks for your quick response, Aaron.

      That is the GREP I used, but it puts the literal “~H” in rather than the actual chapter number variable. Any ideas?

      Elizabeth

    • #82777
      Aaron Troia
      Participant

      Elizabeth,

      I really havent used the Chapter number variable and the times I’ve tried to play with it hoping that it would work, I ended up more confused as why it didnt work like I felt it should (probably because I dont use the Book feature in InDesign). It seems that Variables are only included in Find and not Replace so maybe they arent supported in the Replace field. That’s odd, but the only thing I can think of.

      This might be a little in a different direction, but this article seemed like it might be helpful, or at least along the same lines. They are using the Chapter number but within paragraph styles, mainly bullets and numbering, with the Text faux-GREP which actually surprised me because I never thought to use bullets and numbering this way.

      https://blog.rockymountaintraining.com/adobe-indesign-numbering-chapters-subheads-tables-figures/

    • #82866
      Anonymous
      Inactive

      Thanks for the link and for playing around with this for me. That blog could be a helpful reference for me, even if it’s not in regard to this GREP question.

      From what I can figure out, the only “Find/Change for a chapter number variable” command that works if you copy an instance of that variable and use “replace with clipboard contents” expression. Not ideal, but it will save me some time. I’d love to create a GREP expression that automatically changes it when it comes up within the body text and avoid the Find/Change step altogether. Alas, it seems that is not to be.

      Thanks again for your assistance. It’s so helpful for us GREP rookies!

    • #83799
      Matt Isaac
      Participant

      If i am understanding correctly, you could just use a paragraph style for each chapter name. In the Bullets and Numbering tab use a numbered list and in the list create a new list titled chapters or whatever you’d like to call it (make sure both continue numbers boxes are checked). where it shows “^#.^t” make it say “Chapter ^#” and whenever you need the chapter number just put a space and apply the paragraph style you created to that space. and it will show as “Chapter 1 ” with the ‘1’ being variable

Viewing 5 reply threads
  • You must be logged in to reply to this topic.
Forum Ads