I inserted text field for numbering via fields>variables>number range>text>Arabic. Now I want to get the last value beside it like we do with [page no./ total pages].
Thank you for helping
sample doc with inserted field
sample doc shot
I inserted text field for numbering via fields>variables>number range>text>Arabic. Now I want to get the last value beside it like we do with [page no./ total pages].
Thank you for helping
sample doc with inserted field
sample doc shot
If your goal is to get:
stack exchange
.#[1/3]56
.#[2/3]why
.#[3/3]no vertical
sdf
fd
This is not possible.
You can capture the last value of the Text number range at end of document into a variable, say last. But if try to insert fields like [Number range Text/Show variable last]
in your list, variable last is not yet defined and displays as zero.
There is however a contorted workaround. If you accept the pain and the added difficulty to maintain your document, here is the recipe.
After the last use of the number range, preferentially at end of document to ease maintenance, add a hidden paragraph containing:
Insert
>Cross-reference
, Type Set Reference with name lastText
The paragraph is hidden so that this âtechnicalâ paragraph does not print.
Patch your references to the Text number range to add /
after them and Insert
>Cross-reference
, type Insert reference, selecting lastText and Insert reference to Reference to get the contents of the technical paragraph.
EDIT Sample file AskLOlastNumberRange.odt attached
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.
BTW, please teach me how to capture the last value into a variable. If it canât be displayed, I hope at least it can be used for something else, like for a calculation, right?
If these things involve macros then leave, itâs out of my understanding then. But I may still get a few lines of code.
To capture into a variable, insert a field type Set variable to create a variable and give it a name. In the Value box, type an expression involving other variables and numbers. In your case, the expression is simply Text.
Caution! You can use this variable only after the capture, i.e. you canât forward reference the value.
FYI, Iâve never used a macro yet in a Writer document, even with very sophisticated layout. I canât find my answer to a question about having both footnotes and margin notes automatically positioned without overlap. This is the most complicated layout Iâve ever made. It uses exclusively styles with a special configuration of frame styles.
Read the Write Guide for initial information and Bruce Byfieldâs remarkable tutorial Designing with LibreOffice.
And practice on short test files.
OK, so last value will be captured at the end of all instances and one canât use that value before that as it hasnât been captured yet. But i think we must be able to pump that value above using a simple macro, though thatâs not my cup of tea.
For a macro, see @Luppâs answer.
Without a macro, see my answer above. The idea is to store the last value at end of the document and cross-reference this last value location. It automatically updates when you add or remove items (eventually with Tools
>Update
>Update All
to force cross-reference update (no need for last value as it is always up-to-date).
It was some fun to make something impossible happen with the help of custom code. .
Of course, the code I wrote can be refined in many ways. Have a lot of fun, too.
I donât insert the code here, but recommend to open this attachment (NumberRangeHighExamplExercise.odt) first without the permisson to execute the contained code, to check the code for the absence of malign parts, and then to reload it with permission.
Try to get the code working for you following the guide contained in the REM lines.
Having done so, you can (safely again!) load the next attachment where you find an already completed example. The demo also is containg a suggestion how to protect the needed SetVariable
fields without disturbing the relevant text.
NumberRangeHighExampleDemo.odt
To be very clear: The text fields of type DefineVariable were originbally created with the value 0. The values now shown were assigned by the contrained subroutines. There was no need to find the bottommost occurrence of any NumberRange field type. If there areânt extraordinary many types and much more instances in a document, it is, of course, simple to get the information from the Navigator.
On the other hand the supplied code can rather easily be completed to automate the needed updates even more.
The appropriate documnt events should be âView createdâ and âView going to be closedâ.