global-variableslibreofficeopenoffice-writer

LibreOffice Writer define and use dynamic variables for caption labels


When you insert a caption it automatically increments the value for the caption number e.g if I insert a caption named "Illustration" for each image in my document, LibreOffice will automatically append an integer to my caption such that I get "Illustration 1", "Illustration 2", "Illustration 3" ....

I'm writing a document and sometimes refer to the illustrations in the text. But the diagram for "Illustration 2" may change if I add a new image before it.

Is there a way to dynamically bind the auto increment as a variable in my text? I.e if I add 3 images before "Illustration 2", the image it refers to will become ""Illustration 5".

Can I make my text now refer to "Illustration 5" instead of "Illustration 2"?


Solution

  • You can do this by using a cross-reference field. Let's say you insert your first two illustrations. In this case you can insert a field that refers to your "Illustration 2" by going to Insert -> Field -> More fields, then going to the cross-references tab. Now select the type you're interested in below "type", set "insert reference to" to "category and number", finally select the second illustration under "selection" and press "insert".

    This way if you add 3 more images before the second one, your field will be automatically updated to say 5 after insertion.