4

In a LibreOffice writer document with a field of #temperature_farenheit. Is there a way to create a field named #temperature_celcius that would automatically calculate and insert the correct temperature?

And if this is possible, what types of fields do I use and how do I reference them for purposes of calculations.

BrianWilson
  • 1,653
  • 2
  • 12
  • 16

1 Answers1

6

This can be achieved with user variables. I'll give a start-to-finish example in painful detail for clarity, and hopefully universal applicability to other cases.

  1. Open a new text document.
  2. Enter some text like Water boils at °F (°C).
  3. Put the cursor before °F where you would normally type the number.
  4. From the menus, choose Insert→Fields→More Fields…
  5. Go to the Variables tab. Choose Type: User Field.
  6. Below that, you'll see each User Field gets a Name and a Value. It will not appear in your document, but enter a Name for this variable we're using to store "water's boiling temperature in degrees Fahrenheit," lets say: BoilF
  7. Enter the Value you want stored in that variable, and accordingly shown in this field in the actual document text. Here, its: 212
  8. Click the Insert button to actually add the field to your document. You should see 212 appear in the text.

You've now added the field, but also created a variable that can be used elsewhere. Now to do the math and use it elsewhere:

  1. Leaving the Fields window open, put the cursor before °C.
  2. In the Fields window, select Type: Insert Formula.
  3. Below that, enter the Formula: (BoilF-32)*5/9
  4. Click the Insert button. You should see 100 appear in the text.

Should you ever need to update a number pair, double-click the first number—that is, the User Field in your text. Example steps, using the above starting point:

  1. Add to the sentence so it reads
    Water boils at 212°F (100°C) atop Everest.
  2. It's now wrong, so double-click 212.
  3. The Edit Fields window will appear. In the Value box, enter 154.4 and click the OK button. It will do the math and both temperatures will update in the text.
    Water boils at 154.4°F (68°C) atop Everest.

Be mindful of variable names. If you have 20 temperatures scattered through your text, you should in turn have 20 user variables, with thoughtfully-chosen names.

Joel Reid
  • 955
  • 1
  • 8
  • 14
  • There is no way to update the (BoilF) field without double-clicking it? I would like to directly edit the value. But doing so removes the field. – dpat Apr 04 '19 at 15:25
  • 1
    I don't believe so, no. Both fields are reflecting the variable, one without math, one with. The design choice they made with Writer is that the relationship is not two-directional. – Joel Reid Apr 04 '19 at 19:31