We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question

line number in index

asked 2021-01-19 11:38:15 +0200

solmil gravatar image

updated 2021-01-19 17:51:16 +0200

ajlittoz gravatar image

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 https://drive.google.com/file/d/1bYfL...

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)

edit retag flag offensive close merge delete


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).

ajlittoz gravatar imageajlittoz ( 2021-01-19 12:03:21 +0200 )edit

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.

ajlittoz gravatar imageajlittoz ( 2021-01-19 17:56:38 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2021-01-19 13:26:29 +0200

ajlittoz gravatar image

updated 2021-01-19 19:18:27 +0200

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 ... (more)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2021-01-19 11:38:15 +0200

Seen: 43 times

Last updated: Jan 19