Reference the line number of a bookmark

I have a line-numbered document, and I would like to include in it references to line numbers of other parts of the document that will update as the document is edited. I’m perfectly fine using bookmarks. Is there a way to insert the line number of a bookmark that will auto-update? On the cross-references tab of fields, when I select bookmarks on the left, I see Page, Chapter, Reference, Above/Below, and “As Page Style”, whatever that is, but no line number.

No, I don’t see any way to use the line number as a reference.
IMHO this does not make sense either.
For example, if you use a reference further down in the document to line 3 and three new lines of text were entered starting at line 2, then IMHO the reference is senseless.

Describe in general terms what exactly you want to achieve. Maybe there is another solution.

2 Likes

This is for use in busy, long documents. The reference would be to help the reader find something specific that would not be easy to find with only a page number. It seems to me that giving the line number would be very helpful. But if I manually enter the line number and afterward it what I’m referencing moves to a different line number, it would be detrimental.

Well, I think there are plenty of other ways to work with references in Writer.
Have a look at LibreOffice Help.
Enter " Inserting Cross-References" in the search bar.


And here is the English documentation.

I’ve decided on a better approach to this. Instead of referencing line numbers, I’m going to use numbered paragraphs. This is very simple to use in cross-references.

This is an alternate solution to the one I suggest below but take special care on the way you number your paragraphs in case you need a unique number across your book. Numbered list may not be the right tool.

Another possibility is to associate a footnote to your reference word. The footnote can be the definition or a comment. Afterwards, you can reference the note number just like any other cross-reference.

It is a pity you can’t reference line numbers. As a teacher, I use to put questions such as “tell me the meaning of the phrase «Los mandarines del estado tratan con sus iguales, antiguos compañeros de colegio» on line 15”, or “Tell me the meaning of the second paragraph (lines 8 to 15)”.
Having a softcoded reference would be nice, since a hardcoded reference will change when I print an exam with bigger font for disabled students.
Is there a variable I can use to get the current line number?

@josemoya: No. In Writer, lines like pages have no existence per se. They are a consequence of text flow. Though, both numbers exist internally. It is obvious for page number because you there is a field variable for that. The line number probably exists also, at least for numbering lines in a page but there is no field for it and I bet usage could be difficult (think of a multi-column page style where the margin line number is unique, i.e. page-relative, not column-relative.

If your need is as “simple” as your examples, you could make do with attaching a “label” to your paragraphs. I assume the reference is not very far from the designated paragraph, which relaxes the constraints on the “label”.

You don’t understand the kind of people I made my exams to. They are very illiterate. Also, putting a label to each paragraph (or using underlines, bold and so on) would render it very difficult to read. Well, I could use a paragraph style with tiny numbers, but some of the people suffer presbyopia.

Instead of citing the line number, you can create an “index” of your “specifics”. By “index” I mean some unique label attached to a “specific”.

For example:

In this text, word (ref. 1) "meaning" has an important role.
[…]
See page 3 ref.1 where "meaning" is defined.

You number your references with a number range you create in Insert>Field>More Fields, Variables tab. Give a name of your own like Ref so that it is independent from any other number ranges, notably those used to caption images, drawings, …

  • When you have several references inside a paragraph, you need to help Writer to disambiguate the designation (because the reference dictionary is paragraph-based and you need to point on a definite reference). In this case, select the reference and Insert>Cross-reference choosing Set Reference in Type. Give it a name.

  • When there is a single reference in a paragraph, don’t bother with this additional step.

Where you want to give a pointer to your reader, you Insert>Cross-reference, Cross-references tab. In Type list, you have an item with name Ref. The Selection box shows all paragraphs. Click on the relevant paragraph, then on the required Insert reference to information: Page, Chapter or Numbering.

  • If your reference lies in a multi-referenced paragraph, you must instead choose Insert Reference in Type and select the name you gave to this specific reference.

Thanks!,
I suspect that is more helpful when the goal is for the reader to be able to click on the reference and land on the target.
In my case, I’m dealinig with a document that will be used in printed form. This is why I went with my workaround approach to put all paragraphs into a numbered list and cross-reference them.

Basically my approach is the same with a more targeted scope. I think turning all paragraphs into a huge numbered list will cause much more formatting trouble than a more selective approach, notably if your document already contains numbered lists.

Correctly configuring numbered lists across a document is one of the most difficult tasks in Writer. The numbered-list button in the toolbar is a very poor surrogate for this task and has severe limitations. The full solution goes through a combination of paragraph+list styles and is not elementary.

That may be the case. Nonetheless, the numbered list approach is working for my needs.

I think you missed my objective. I want to make it really easy for a reader of a printed copy to find what’s being referenced in the text. A page number will not get them close enough, and a link will not help at all since it’s printed.

I see there are 2 likes on the original post. I posted an enhancement request for this functionality to be added on the bug tracker https://bugs.documentfoundation.org/show_bug.cgi?id=146905.
So far, the status is still on unconfirmed. If you also want to see this added, please comment on it to that effect.

@agerber85: I understand your concern about reader friendliness. Unfortunately, the built-in reference tool can’t be closer than one page. To narrow down even more the location, you can:

  • insert a text frame anchored to the character of the exact location you want to point out (first character of word of expression, middle, end; it’s up to you); position this frame in the (outer/left/right) margin
    this frame will always follow the location, no matter which edits affect to your document
  • inside the frame, enter some unique label, number or bullet
    I don’t recommend numbering them automatically because the ordering follows creation order, not reading order; this could upset you as the author and even more the reader
  • cross-reference (Set Reference) the label, number or bullet; take care to select the whole label before cross-referencing

Where you want to insert a pointer to the labelled location, insert a cross-reference (Insert Reference) choosing the appropriate label; page number is available with Page property and the label itself with Reference (this is why it is important to completely select the label before creating the reference otherwise text is truncated).

For ease of processing and consistency all over the document, store your frame settings in a frame style.

Have a look at the attached sample file AskLO-MarginRef.odt (13.8 KB). I played a bit with frame style MarginRef. View>Field Shadings is enabled, so display may look weird. Use print preview to get an idea of the final result.

PS: your enhancement request makes sense and would be really useful. However, the choice is valid only if line numbering is enabled Tools>Numbering.

1 Like

@ajlittoz Thanks so much for taking the time to play with that. However, for our situation, having to create those text frames is a cumbersome enough process that it wouldn’t end up happening.

True enough. I’m sure that could be overcome by a message if that choice is selected without line numbers enabled asking whether they should be enabled.

Can you use paragraph numbering per chapter? See attachment:
Numbering.odt (13.6 KB)

I put it on small pages to show better how it behaves without having to provide lots of text.

I wouldn’t recommend attaching Text Body to outline level 10 as you do. The paragraphs are not numbered “per chapter” but per the deepest Heading n used, in the present case chapter because only Heading 1 is used. This may present disturbing effects to the reader if the numbering is not clearly explained.
It forces to alter all paragraph styles to be attached to the outline level (with the complication of succeeding to get continuous numbering) and consequently it prohibits list usage, unless list numbering is considered a sufficient reference system so that paragraph numbering is suspended within lists.

1 Like

Thanks! I suspected that shoving text body into structural elements might be problematic. Just started to test with multilevel subdivisions, but as you say, this may be forbidding even as a workaround (awaiting the response to feature request).

@agerber85 : If at all you attempt to use this (which I have yet to explain in detail), do not make a change in your original document. Make backups. Work on a copy of your product. Be safe!

1 Like