Contents | Start | End | Previous: KB0395: Why are my headings numbered twice in ODT? | Next: KB0397: How do I apply automatic heading numbering but exclude the first few chapters?


KB0396: How do I add a cross-reference to an automatically numbered heading?

See also:
How do I add or remove automatic heading numbering?
Working with numbered headings in the Jutoh manual
Working with fields in the Jutoh manual
Working with link styles in the Jutoh manual
Cross-reference dialog in the Jutoh manual

Cross-references to headings are special links that will be updated when automatic numbering changes or the heading text changes (after you compile the project or use Book | Update) so can save time compared with typing the text manually and linking to a chapter heading.

To use automatic heading numbering, you can check Number headings automatically in Project Properties/Fields & Numbering and adjust the document outline to match the heading style (from the same Fields & Numbering page).

If you have a chapter heading "My Heading", you can achieve "Chapter 1: My Heading" by editing the document outline for the level 1 heading and setting Separator before to "Chapter " and Separator after to ":". You should not add a space after your text for Separator after as this will be added automatically.

Now you can create a reference to the heading (currently, just the top-level chapter heading) by doing the following:

  1. Use the menu command Format | Insert | Links | Cross-Reference to show the cross-reference dialog.

  2. For Reference type, choose Heading.

  3. In Items, click on the heading you want to link to.

  4. Click on the Format you wish to see, such as Chapter (just the chapter number, in our example showing just "1"), Number (number and separator text, "Chapter 1:") or Text (the actual heading, e.g. "My Heading").

Cross-references are based on the OpenDocument (ODT) model, which unfortunately doesn't have a built-in way to insert a single cross-reference that shows the entire heading ("Chapter 1: My Heading"). However, you can achieve this by inserting two cross-references to the same heading, using the Number format first, and the Text format second, typing a space inbetween the two.

Jutoh adds two 'unofficial' formats you can use with the Heading type: Category and number (shows e.g. "Chapter 1") and Full text (shows e.g. "Chapter 1: My Heading"). These will output a simple link to ODT, not a cross-reference, since there aren't official equivalents.

If you use the separate Number and Text fields approach, the space inbetween will not be underlined and coloured blue in HTML, Epub and Kindle formats, whereas the two other pieces of text will be. In OpenDocument, cross-references are not highlighted anyway, so the difference will not be visible. If you want to remove highlighting for cross-references for the other formats, to reduce visual clutter and fix the differently-formatted space problem, you can add a link style in the Jutoh manual that removes the highlighting. Here's how:

  1. Click on Edit in the toolbar and go to the Styles page.

  2. Click Link Styles.

  3. Add a new link style, and name it e.g. "Cross-References".

  4. Set Underlining to None, Text Colour to None and Background colour to None.

  5. Click on the Defaults tab and for Cross-reference, select your new link style, "Cross-References".

  6. Click OK, then OK.

Although cross-reference links will still be shown with URL formatting in the Jutoh project, the formatting will be removed in generated books.


Contents | Start | End | Previous: KB0395: Why are my headings numbered twice in ODT? | Next: KB0397: How do I apply automatic heading numbering but exclude the first few chapters?