Skip navigation
wbset09
Currently Being Moderated

Grep style - add brackets around number

Apr 12, 2012 10:33 AM

Tags: #toc #indesign #grep

Hi there,

 

I am wondering if there is a way to use GREP styles to apply brackets around a number. I am looking for it to be a grep style (within the paragraph style) and not a find and replace.

This will be used in an automated table of contents where the page number will be in brackets. (Is this something I can specify in TOC settings?)

 

Like such:

 

Contents

Chapter One     [3]

Chapter Two     [10]

Chapter Three  [15]

 

Again, it needs to be part of the paragraph style (or TOC settigns) so the brackets are automatically applied to numbers when the associated paragraph style is used.

 

Hope someone can help me out!

Thanks!

 
Replies
  • Currently Being Moderated
    Apr 12, 2012 4:59 PM   in reply to wbset09

    GREP styles cannot add glyphs. While you can add the braracket before the number in the TOD settings, there is no way I know to add it after other than find/change or possibly a script.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2012 2:46 AM   in reply to Peter Spier

    Try this:-

     

    Go to Edit-->Table of Cotents

     

    in the Tabke of Content dialog box , click on "more options" to have the complete options (by default some are hidden)

     

    In the Table of Content dialog box , look for "Between Entry and Number" , there would be text "^t" (basically this is the tab character) , after this type "[" , so the

    complete text in "Between Entry and Number" will look like "^t["

     

    Then Update your table of content , and every entry in your table of content will have the "[" infront of it....now it will much easire to run "GREP"

     

    -----------------------------------------------------

     

     

    Go to Edit-->Find/change

     

    go to GREP tab

     

    In "Find what" put:-  \[\d+

     

    In "Change to" :- $0]

     

    now , click on the "find next' to see the entry of the Table of content and "Change' to change the entry to like [3], [4] etc

     

    Drawback of this workflow:--  Every entry in the document will be serached not only the TOC hence if incase your document has entry of kind :- [356 , [34 , they will be searched and changed so be cautious for that

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2012 4:24 AM   in reply to Manish-Sharma

    There is no particular advantage to adding the bracket before the number in the TOC since you have to run the find/change anyway.

     

    You can search for \t(\d+) and chage to [$1] and get the same thing without adding the bracket first.

     

    Also, there is no need to search the entire document. Set the scope of the search to Story and only the TOC will be affected (TOC must always be a self-contained story).

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2012 4:34 AM   in reply to Peter Spier

    Great point, I believe I overthink sometime.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2012 5:58 AM   in reply to Manish-Sharma

    Don't we all.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2012 9:53 AM   in reply to wbset09

    Styles have never been intended to add content, and never will be (aside from things like underlines, paragraph rules and bullets and list nembers, all of which are considered "adornments" and cannot be selected).

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2012 12:40 PM   in reply to Peter Spier

    Think in this way, Glyphs is not defined set , every font has its on Glyph sets

     

    and in that set every glyph has its own Unicode , which is Unique.....to include it in the GREP , we have to make the GREP font dependent ......and GREP will loose its basic functionality because it will not be able to serach the document just the fonts.

     

     

    Hence including Glyphs in GREP will screw up the things

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points