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-string for specific text between parentheses

Return to Member Forum

  • Author
    Posts
    • #34207

      I’m working on the lay-out of a Dutch textbook on project management, in Indesign.
      Instead of footnotes, the source references and literature used are put between parentheses, e.g: (Richardson, 2010, p. 3) or (Camilleri­, 2011, pp. 4-5). I want to stylize these instances of secondary information in a condensed font to make them subtly stand apart from the body copy itself. I used a grep-string to help me achieve this. So far, so good. But still, now all text strings between parentheses are formatted ? not only that source material I was aiming for.

      However 90 % of the affected text strings is such a reference to sources or literature, there are still other instances of text between parentheses which I dont want to stylize with a separate character style, such as acronyms or words used as an aside.

      My question is:
      How do I make my grep-string more specific to fit these literature references?

      They start with capitalised names (one or more authors), they always end with one or more digits (page reference), and they ? most of the time but not always ? have a 4 digit date indication in between. Again, e.g.: (Pemsel & Wiewiora, 2013, p. 31)
      This is a sample of text:
      — Het Project Management Institute (PMI), de van oorsprong Amerikaanse beroepsvereniging voor projectmanagers die ondertussen ook in tal van andere landen waaronder België een afdeling heeft, definieert een project zeer kort als ?a temporary endeavour undertaken to create a unique product, service or result? (Richardson, 2010, p. 3). —

      Is it helpful to put a marker in these literature references in the original Word-file? Can I locally “override” grep with a “none”-style (I doubt it, hierarchy)? Or should I leave the grep-method and manually stylize these text strings (e.g. apply formatting with eye dropper to the literature references in the end, and then finally disable grep in my bodytext paragraph style)?

      Feel free to help me out with this problem.

    • #34214

      You don’t say what GREP you are using now, but I guess it’s something like this:

      \(.+?\)

      — very simple, “pick up everything inside parentheses”. Let’s go through your specifications:

      1. “start with capitalized names”:

      \(\u.+?\)

      already works a treat. The only extra it picks up is your remark “(I doubt it, hierarchy)”.

      2. “end with one or more digits”:

      \(\u.+?\d\)

      Hmm. For some reason this picks up too much text — it crosses over a closing parenthesis! (Which is not an “error” per se, but rather an unexpected interpretation of the Rules. Careful examination shows it still does EXACTLY what you ask for!)
      An alternative notation works as expected:

      \(\u[^)]+\d\)

      3. “most of the time, a 4 digit date”:

      GREP cannot handle ‘most of the time’ … But if you find the last expression skips occurrences that for some reason do not end with a digit but DO contain a year, you can add this as a second GREP style:

      \(\u[^)]+\D(19|20)\d\d(?!\d).*?\)

      .. it matches capitalized name, then Not-A-Digit, followed by either “19” or “20” and two digits, and then just about anything up to a closing paren.

      4. “override GREP with none”:

      No– but you CAN override a GREP style with a character style that applies the original font again, not ‘removing’ the font but rather overriding it a second time. But I would only do so in case of an acute emergency — it’s better to make your GREP styles work for you instead of fighting them.

Viewing 1 reply thread
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads