The Problem:
Normally Publishing Assistant puts a chapter range in the header, for example 28-30. How can I change this to say 28, 29, 30?
Solution:
The first step is to get the exact character codes used in chapter ranges in headers. Highlight the character in a header in InDesign and go Window > Info. Pay close attention to whether there are spaces (e.g. zero width spaces) around the character.
One example I looked at was “Nambas 29–31”. Using the Info dialog box in InDesign, I was able to get these character codes:
- b (U+0062)
- a (U+0061)
- s (U+0073)
- Figure space (U+2007)
- 2 (U+0032)
- 9 (U+0039)
- Zero width space (U+200B)
- En-dash (U+2013)
- Zero width space (U+200B)
- 3 (U+0033)
- 1 (U+0031)
So, in this case chapter ranges are marked with u200Bu2013u200B. It’s also important to notice that there is a figure space (U+2007) before the first chapter number.
The second step is to determine the exact character codes desired between numbers in a list. It might be something simple like comma (U+002C) and figure space (U+2007).
In PA open HeaderChanges.txt (Menu > Edit > Edit HeaderChanges.txt).
At the end add one line which converts “1-2” into “1, 2”. Using the character codes figured out above, that would be:
"u20071u200Bu2013u200B2" > "u20071,u20072"
We could add a helpful comment at the end, just to clarify what’s happening
"u20071u200Bu2013u200B2" > "u20071,u20072" # "1-2" > "1, 2"
Repeat this line 149 times and replace the chapter numbers so that the changes file now looks something like:
"u20071u200Bu2013u200B2" > "u20071,u20072" # "1-2" > "1, 2" "u20072u200Bu2013u200B3" > "u20072,u20073" # "2-3" > "2, 3" ... "u2007148u200Bu2013u200B149" > "u2007148,u2007149" # "148-149" > "148, 149" "u2007149u200Bu2013u200B150" > "u2007149,u2007150" # "149-150" > "149, 150"
Between the first two lines, add a line which converts “1-” into “1, 2-”. Using the characters codes we figured out above, that would be
"u20071u200Bu2013u200B" > "u20071,u20072u200Bu2013u200B" # "1-" > "1, 2-"
Put a similar line to this between all the pairs of lines that already exist, adjusting the chapter numbers as appropriate. The changes file now looks like:
"u20071u200Bu2013u200B2" > "u20071,u20072" # "1-2" > "1, 2" "u20071u200Bu2013u200B" > "u20071,u20072u200Bu2013u200B" # "1-" > "1, 2-" "u20072u200Bu2013u200B3" > "u20072,u20073" # "2-3" > "2, 3" "u20072u200Bu2013u200B" > "u20072,u20073u200Bu2013u200B" # "2-" > "2, 3-" … "u2007147u200Bu2013u200B148" > "u2007147,u2007148" # "147-148" > "147, 148" "u2007147u200Bu2013u200B" > "u2007147,u2007148u200Bu2013u200B" # "147-" > "147, 148-" "u2007148u200Bu2013u200B149" > "u2007148,u2007149" # "148-149" > "148, 149" "u2007148u200Bu2013u200B" > "u2007148,u2007149u200Bu2013u200B" # "148-" > "148, 149-" "u2007149u200Bu2013u200B150" > "u2007149,u2007150" # "149-150" > "149, 150"
At the very end of this document you will find the complete file. You can copy and paste it into headerChanges.txt for your job. If your job uses different character codes, you can do a global replace for “u200Bu2013u200B” and “,u2007”.
How does it work?
If you don’t care how it works, skip to the bottom of this document and you will find the file. But, if you happen to be curious about such things, read on.
For this explanation, it’s helpful to know that the changes in HeaderChanges.txt are applied one at a time.
Suppose that a header contains “Numbas 28-31”. The first change to apply is:
"u200728u200Bu2013u200B" > "u200728,u200729u200Bu2013u200B" # "28-" > "28, 29-"
And the result is “Numbas 28, 29-31”. The next change doesn’t apply:
"u200729u200Bu2013u200B30" > "u200729,u200730" # "29-30" > "29, 30"
So the header still contains “Numbas 28, 29-31”. The next change applies:
"u200729u200Bu2013u200B" > "u200729,u200730u200Bu2013u200B" # "29-" > "29, 30-"
And now the header contains “Numbas 28, 29, 30-31”. The next change applies:
"u200730u200Bu2013u200B31" > "u200730,u200731" # "30-31" > "30, 31"
Giving the final result “Numbas 28, 29, 30, 31”.