line number in index

Is it possible instead of or in addition to page number to display the line number of an indexed item in the index.

If so, how?

My requirement is that I am using line numbers and page numbers in a document. I need to produce an index of bits of text in the document which appears as an index at the end of the document. What I need to display is

The text. the page number. the line number

or in the case I’m using continuous unique line numbers from the start to the end of the document.

The text. the unique line number.

Here is an example just using page number as per normal

What I need is to INCLUDE line number in the Index table, eg


Blyth v. Bloomsbury Health Authority                  p1 line15
Gold v. Haringey Health Authority (1987) 3 WLR 649.)  p1 line16
Gover v. South Australia (1985)	                      p1 line10
Hills v. Potter (1984) 1 WLR 641                      p1 line15
Maynard v. West Midlands R.H.A                        p1 line15
Sidaway v. Governors of Bethlem Royal Hospital (1985) p1 line8
Whitehouse v. Jordan                                  p1 line14

or if continuous line numbering in a document:


Blyth v. Bloomsbury Health Authority                  line15
Gold v. Haringey Health Authority (1987) 3 WLR 649.)  line16
Gover v. South Australia (1985)                       line10
Hills v. Potter (1984) 1 WLR 641                      line15
Maynard v. West Midlands R.H.A	                      line15
Sidaway v. Governors of Bethlem Royal Hospital (1985) line8
Whitehouse v. Jordan                                  line14

Many thanks.

(formatting of the examples edited by ajlittoz)

This is not possible out of the box.

However, if you edit your question to provide more details about your goal, perhaps we might find a solution.

Is the line number really the line number within the page? If the indexed item lies within a table or a numbered list or any other specific identified sub-part of your document, there may be a workaround.

Please do not use Add Answer but edit your original question to enhance the details of your question (answers are reserved for solutions to a problem on this Q&A site).

In the referenced sample, you show a “standard” index. Your text has “(#)” before each reference. I assume that these reference numbers could be what you call “continuous line numbering in a document”. These numbers can be made part of the index entry, but your entries must be kept in alphabetical order, i.e. the number must not disturb this order.

See my updated answer.

A unique number may be added to any kind of “object” or text. However, there is no way to alter the page number information in the index table to format it as “page-id” (with id equal to the unique number). This defeats the “merging” behaviour of an index. The closest which can be done is to include the unique number in the index key but this will give:

indexed term (5) …………10
indexed term (7) …………12
other term (3) …………………8

instead of

indexed term ………10-5, 12-7
other term ………………………………8-3

The index entry may need special care depending on how you want to display and format the unique number. In particular, this could require cross-references to copy the unique value without incrementing it.

Unique numbering: this is done through a number range. Writer provides already 5 number ranges: Drawing, Figure, Illustration, Table and Text related to auto-captioning. See Insert>Filed>More Fields, Variables tab. You can define others for your special needs so that there is no interference with the built-in usages.

Edit your question to provide an example of the formatting of the “line” to be indexed so that I can give you implementation suggestions.

EDIT 1 Use of margin reference numbers

This is contorted and tricky approximation to the goal. See this revised sample file


I define a new number range “Authority” to number the indexed references. However when a number range occurrence is attached to a paragraph, only the first one (in this paragraph) can be cross-referenced. Consequently where there are several index entries in the same paragraph, the reference number must be attached somewhere else. I chose frames in the margin.

Creation of reference number

For ease of formatting, create a new frame style Ref with the following properties:

  • in Type tab: Width 1 cm, Height 0.5cm AutoSize; Position horizontal From left -0.1cm to Right paragraph border; leave vertical **Spacingas is because anyway you can’t set it adequately here
  • in Wrap, reduce Spacing top and bottom to 0.1cm or less and untick Allow overlap

At the beginning of the index entry, Insert>Frame anchored To character. This anchoring mode is very important because you have several “references” in paragraphs.

Quit the frame and style it Ref by double-clicking on the style name.

Right-click on the frame and Properties. In Type, check the horizontal position is From left -0.1cm to Right paragraph border otherwise fix it. Set vertical position to Center to Character.

The reason why the horizontal position can’t be set in the style frame is the style does not record the anchoring mode. Thus this requires to adjust manually every frame.

Put the cursor inside the frame. Insert>Field>More Fields, Variables tab.

  • The first time, select Number range in Type, enter Authority in the Name box and push Insert.
  • Afterwards, Number range should already be selected, click on Authority and press Insert.

The reference number is now in the margin

Entering the reference number in the index entry

As you need the number in the index, it must be somehow added to the index entry. This is done with a cross-reference so that addition, deletion or move of entries automatically update the counter.

At the end of an index entry, add a “prefix of your taste” (in the sample I used “<space>#” and Insert>Cross-reference, Cross-references tab. In Type, select Authority, in Insert reference to Numbering and choose the right number in Selection. Press Insert.

IMPORTANT: make sure this cross-reference is part of the index entry (it should have a gray background like the rest of the entry).

You must now ensure that this added “technical” number does not print. Create a new character style Hidden. Its only property is in Character Effects where you tick Hidden. Select the “prefix” and cross-reference, apply style Hidden.

You can check with print preview that the “technical” number does not print.

Update the alphabetical index to see the reference.


  1. In the sample, the reference number frames are widely spaced apart. This was before I reduced the spacing in the wrap tab. It was caused by the automatic positioning due to “no overlap”. Unfortunately, it appears changed in frame styles do not propagate well back to the frames.

  2. I left your original index in the sample so that you can see the difference. I must admit that the reference number does not stand out in the index. You’ll have to imagine a “good” prefix.

  3. This is the closest I can do.

  4. I highly recommend you use customised styles in your document (the sample was single-styled with Default Paragraph Style which is faulty). Also don’t vertically space with empty paragraph. Vertical spacing should be part of the paragraph style.

  5. I also highly recommend you work with View>Formatting Marks enabled and the options to see hidden text otherwise you’ll quickly get lost. Remember this is only for screen and does not change what is printed or PDF’ed.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

In case you need clarification, edit your question (not an answer which is reserved for solutions) or comment the relevant answer.