Custom Running Headers

This script is part of the Book and Long Document Composition/Production collection. See the full collection here.ย 

Running headers can be placed in InDesign by using text variables. This is a useful feature, but unfortunately there are some problems:

  1. Styling in a heading is dropped in the running header. Thus, the heading The etymology of flimsy appears as The etymology of flimsy in the running header.
  2. Automatic paragraph numbers are dropped. Though this is in my experience usually correct, nevertheless some publishers want the number to be included.
  3. Text variables can contain just one line: line breaks are not possible.

These problems are well documented and have been noted and discussed in various forums, and feature requests and bug reports have been submitted โ€“ all to no avail. Some of these problems can be handled by a third-party plug-in sold by In-Tools,ย PowerHeaders; it has a number of attractive additional features to boot.

However, on top of these problems I needed functionality to specify short titles for running headers when the running header’s text is too long. Some heading titles simply don’t fit; and some publishers stipulate that a running header shouldn’t be longer than two-thirds of the text measure.

To cater for these requirements, the script discussed on this page deals with all this. The document I use for illustrating the set-up is attached as well.

Assumptions

The script and the set-up are geared towards a format common in sholarly publishing. There are essentially two types of layout for running headers:

  • In edited volumes each chapter has the author(s) in the running header on the versos, the chapter title on the rectos. This type of layout is usually handled fine by InDesign.
  • In single-author publications, chapter titles are in the running header on the versos, level-1 section headings are on the rectos. These are often problematic for InDesign; the script discussed here is designed specifically to deal with this type of layout.

Document set-up

Open the attached document. Enable Normal screen mode (View > Screen mode > Normal) to expose all special characters. The document has two parent spreads, one for the chapter’s first page (O-Opener), the other for the body of the text (M-Main).

The chapter opener

The first page has two text frames. One contains the chapter title (entered manually). The second one is a configuration frame that tells the script whether it should include section numbers in the running headers. The sample says ‘yes’; if you don’t want the numbers replace ‘yes’ with ‘no’. The frame is labelled Config on the Layers panel. If the script can’t find the frame or can’t interpret its content, the script uses InDesign’s default, which is not to use paragraph/section numbers. These two frames are on a non-printing layer.

Running headers: set-up first page

The body of the text

The parent pages used for the body of the text contain a running-header frame each. The left-hand pages are handled in the usual way, so I’ll focus on the right-hand page. The frame is labelledย Running headerย on the Layers panel and a dedicated paragraph style is applied to the frame. The content is a page-number variable (the M in the illustration, which is the parent page’s prefix), preceded by an em-space (change to whatever you need) and an end-nested-style-here code (the blue backslash; if you don’t see it on your screen, enable Normal screen mode: View > Screen mode > Normal).

Running headers: set-up first page

The end-nested-style-here code is used as a delimiter so that the script can be run again at some later stage: it needs to remove the header’s content, but not the page-number variable and the space before it.

Styling running headers

InDesign’s text variables strip all formatting from referenced text, which is one of the big complaints about them. The script preserves character styles, local overrides are removes (out of necessity, can’t be avoided). Character styles in running headers will probably need some updating.

Running headers are often set in italics. You can’t set that in the runing header’s paragraph style because the page number should stay Roman and if you include section numbers, they too may have to stay Roman. To handle this, use a nested style to apply italics to part of the running header.

For another approach to styling in text variables in running headers, see here.

Short titles

When a section heading is too long it’s useful to have a mechanism to provide short titles. I borrow the method used in Latex, which is to add a short title in brackets before the long title. An example is op page 4 of the attached sample document.

Open the story editor (Edit > Story editor) to expose the full title. The short title (Temperature measurements in the example) is in brackets. It’s made invisible by the character style Short title, which sets the type size to 0.1 points, the horizontal scale to 1 per cent, applies superscript (for even more reduction), an applies the Paper colour. The script places this short title, not the full title, in the running header.

Running headers: set-up first page

Note: Naturally, this short title appears in the table of contents as well. After generating it, the table of contents should be updated manually.

Running the script

The script has no interface. Before you run it, indicate whether section numbers should be included in the running headers (see above). Then place the cursor in one of the numbered headings that should be used in the running headers and run the script.

If texts edits can have moved headings to another page or if any changes are made in section titles, the script should be run again.


Version history

August 2024: Posted.

Peter Kahrel Script Repository
Hosted as a community service, and with deep appreciation, by CreativePro.com


Scripts by Topic | Script Index
Basic Script Installation and Use
How to Modify or Configure These Scripts
Resources for Scripting and Publishing Automation
About This Repository


Repository Home Page


Contact Peter Kahrel


Note to users: You run scripts at your own risk: CreativePro and the author accept no liability for anything that may be caused by any of these scripts. Always take the necessary precautions. We encourage you to save backups and test scripts on copies of your documents.

Bookmark
Please login to bookmark Close

This article was last modified on August 22, 2026

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading comments...