I am writing a textbook with Adobe InDesign that has optional sections. These sections have a tab then a flag at the right end of the tabs. I am wondering if in the TOC, how should I treat the TOC prior to refain myself to Find (the tab and image) and Replace (to styled text) at each updates of TOC?

This is the example after treatment.

This is the example after treatment.

  • 3
    I'm not really understanding this question. – Scott Jan 2 '15 at 17:08
  • @Scott My understanding is they want the (opt) "flag" in the TOC-entry to use a different character style, so I propose using a GREP style – Tobias Kienzler Aug 30 '16 at 9:10

You can use InDesign's GREP styles for that.

First of all, create the character style "option", which is set to your needs (if it doesn't already exist).

Modify the TOC format such that a right aligned tab (\y) is used before the page number instead of a usual one (\t).

Then modify your TOC-entry's paragraph style (if you're using the same as the original paragraph, you need to copy the style, optionally with the original as its base) and select "GREP styles". Here, add a new entry using the "option" format to anything matching
(?<=\D\t).+(?=~y\d+$) (click the link for an explanation, except that we're using ~y to match the right-aligned tab instead of a regular tab). Also remove the regular tabulator position of this format!

The RegEx above will match anything that your title has after a tab. Alternatively, you can of course simply have it match \(opt\) (the parentheses must be \-escaped in RegEx).

  • 1
    Will try, but I haven't been touching InDesign for a long time. Since I was using LaTeX to do all the science documents. – SHY.John Sep 9 '16 at 1:16
  • But the solution seemed pleasing to me – SHY.John Sep 9 '16 at 1:18
  • Yeah, I was about to comment how you could probably achieve this better with LaTeX when I saw you've been more active on TeX.se :D – Tobias Kienzler Sep 9 '16 at 18:27
  • LaTeX is better of from making equations into images each time. But I have to use Illustrator to get the images done, Tikz take too long. =) – SHY.John Sep 10 '16 at 11:16
  • 1
    I ended up not using GREP but the nested styles. So what I have done is I set the first nested style as NULL with "at most 1 tab mark", then the CHAR-STYLE-YOU-WANT with "in 2 tab marks". – SHY.John Nov 2 '16 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.