Copy Just Part of a Chapter Title to a Header

Here’s a fun challenge: I have a chapter title here that has some extra text in it—in this case, an em dash on either side of the text.
I want to put that chapter title in the headers in my chapter, but I don’t want those dashes. Similarly, I want to the put the author’s name in the header, but I don’t want the word “by” or the person’s degree or title… just the name.
Normally the way you put text like this in a running head or footer is to use a text variable, which you can find by choosing Type > Text Variables > Define:
And then you create a Running Head variable that is based on the paragraph style of the Chapter Title, and another one based on the paragraph style for the Author:
But this won’t work in this situation because it picks up all the text from the paragraph style, including the em dashes and the “by” and so on. So we need a trick.
(By the way, this excellent question was first posed by Ginger Marks on our InDesignSecrets Facebook group, and key insights were made by Peter Goodman, Brett Stone, and Keith Snyder. A big thank you to them!)
OK, so instead of making the text variable based on the paragraph style, you need to make it based on a character style. But then you need to apply the character style to the correct text, which can be annoying if you do it manually for a lot of chapters. So tell InDesign to do it automatically!
First, let’s make two character styles that do nothing… they don’t apply formatting at all. One is going to be for the text in the chapter title, and the other will be for the author.
Next, in your chapter title style, add a nested style that applies None to the text before the real chapter title — in this case, “through the em dash.”
(If you don’t know this trick, you should: Normally, the nested style is “through 1 word.” But you can replace the word “Word” with any character you want! Here I just typed an em dash, which is Command-Option-dash or Ctrl-Alt-dash.)
OK, now we want to add a new nested style that applies a character style to the text, so we’re going to say “up to” another em dash:
That’s it! Now save that and edit the Author paragraph style to have a similar set of nested styles:
See how that applies the character style to just the author name?
Now that we have character styles applied to the stuff we want to capture, we can return to the Define Text Variables dialog box and make two new variables. But in this case, we’re going to make them based on character styles instead:
Finally, we can insert those text variables (using Type > Text Variables > Insert Variables) into text frames on our master page:
And the result is perfect:
Now, when this is applied in every chapter, the running heads will update automatically as the chapter title and the author names change—ignoring the extra characters we don’t need!
This article was last modified on July 7, 2021
This article was first published on January 30, 2019
Thank you for this tip.
Is it possible to remove the header from the first page for each chapter?
Or keep header on each page but add “(suite)” after the first page for each chapter?
Hi, you don’t need to use a different master page. Create and apply a paragraph style (for instance, titleFirst) to the first element and apply a paragraph rule.
In this case, you could work with Layers.
The ruler hides the variable.
Personally, I have a separate master page for chapter starts. I’m doing a book at the moment and have an image of a statue of the subject of the biography top right on the first page of the chapter. Having a separate master page allows me to start the chapter lower down the page. I could have two (or more) text boxes linked so that the chapter title is always in the same position and the text begins at exactly the same spot (where sometimes chapter titles take up more than one line). Mastermatic will automatically apply the right master page based on the chapter title style sheet. Or there’s a free script that will do much the same written by (I think) the wonderful Peter Kahrel.
I used to use different master pages for each chapter. It was a pain, especially in a book with up to 50 short chapters (something that long I might now use the book function). Then I discovered text variables and this method a couple of years ago. Now I just use the same master page for every chapter. So much easier. I sometimes use the “End nested style here” character to mark the start and end of text when it isn’t always obvious which text should be picked up. Especially useful for excessively long chapter titles.
Does this also work with GREP styles?
I tried and I didn’t succeed. A Grep search and find to mark the text works. Best Regards from Paris, Olivier
I believe when I’ve tried in the past it doesn’t work, that’s why this is a good workaround. I think it’s more to do with the fact that grep is applied ‘on the fly’.