LibreOffice Logo

Math Guide 25.2

Chapter 2,
Formulas in Writer

Copyright

This document is Copyright © 2025 by the LibreOffice Documentation Team. Contributors are listed below. This document may be distributed and/or modified under the terms of either the GNU General Public License (https://www.gnu.org/licenses/gpl.html), version 3 or later, or the Creative Commons Attribution License (https://creativecommons.org/licenses/by/4.0/), version 4.0 or later. All trademarks within this guide belong to their legitimate owners.

Contributors

To this edition

Peter Schofield

For previous editions

Agnes Belzunce, Bernard Siaud, Christian Kühl, Daniel Carrera, Dave Barton, Florian Reisinger, Frédéric Parrenin, Gisbert Friege, Hazel Russman, Ian Laurenson, Janet M. Swisher, Jean Hollis Weber, Jochen Schiffers, Laurent Balland-Poirier, Michele Zarri, Olivier Hallot, Peter Kupfer, Peter Schofield, Rafael Lima, Regina Henschel, Roman Kuznetsov, T. J. Frazier.

Feedback

Please direct any comments or suggestions about this document to the Documentation Team Forum at https://community.documentfoundation.org/c/documentation/loguides/ (registration is required) or send an email to: loguides@community.documentfoundation.org.

Everything sent to a forum, including email addresses and any other personal information that is written in the message, is publicly archived and cannot be deleted. Emails sent to the forum are moderated.

Publication date and software version

Published April 2025. Based on LibreOffice 25.2 Community.
Other versions of LibreOffice may differ in appearance and functionality.

Using LibreOffice on macOS

Some keystrokes and menu items are different on macOS from those used in Windows and Linux. The table below gives some common substitutions used in this document. For a detailed list, see LibreOffice Help.

Windows or Linux

macOS equivalent

Effect

Tools > Options

LibreOffice > Preferences

Access setup options

Right-click

Control+click, Ctrl+click, or right click depending on computer setup

Open a context menu

Ctrl or Control

⌘ and/or Cmd or Command, depending on keyboard

Used with other keys

Alt

⌥ and/or Alt or Option depending on keyboard

Used with other keys

F11

⌘+T

Open the Styles deck in the Sidebar

Introduction

When a formula is inserted into a document, Writer inserts the formula into a frame and treats the formula as an OLE object. For more information on creating and editing formulas, refer to Chapter 1, Creating and Editing Formulas.

This chapter explains what options can changed for a formula within a Writer document. See the Writer Guide for information on how to change the settings for frame styles for OLE objects.

Figure 1: Example formula selected for editing in Writer

Example formula selected for editing in Writer

Automatic formula numbering

Automatic numbering of formulas to create formula cross references can only be carried out in Writer. The AutoText entry fn (formula numbered) is used to automatically add a numbered cross reference to formulas.

Numbering

  1. Start a new line in a document at the required position for the formula.

  2. Type fn and press the F3 key to insert a two column table with no borders. The left column contains a sample formula and the right column contains the cross reference number, as shown by the following example.

E=mc2

(1)

  1. Delete the sample formula and insert the required formula into the left column.

Formula cross referencing

  1. Click in the document at the position where a cross reference for a formula is required.

  2. Go to Insert > Cross-reference on the Menu bar to open the Fields dialog (Figure 2).

  3. Click on Cross-references, then select Text in Type.

  4. In Selection, select the formula number required for the cross reference.

  5. In Refer using, select Referenced text, then click on Insert to insert the cross reference for the selected formula.

  6. Click on Close to close the Fields dialog.

Figure 2: Fields dialog — Cross-references — Referenced text

Fields dialog — Cross-references — Referenced text

To use square parentheses instead of curved parentheses, or require the cross reference number to be separated from the formula by tabs instead of using a table, see the Writer Guide for more information.

Anchoring and aligning formulas

Anchoring position

A formula is an object when inserted into a Writer document. The default anchoring for a formula is As character when inserted into a document. To change the formula anchoring in a document:

  1. Right-click on the selected formula and select Anchor from the context menu.

  2. Select an anchoring option from the context menu. The anchoring options available are To paragraph, To character, or As character.

  3. Alternatively, right-click on the selected formula and select Properties from the context menu, or go to Format > Frame and Object > Properties on the Menu bar to open the OLE Object dialog (Figure 3).

  4. Make sure Position and Size is selected, then select a new anchoring position from the options available in Anchor. The anchoring options available are To page, To paragraph, To character, or As character.

  5. Click OK to save the changes and close the OLE Object dialog.

Figure 3: OLE Object dialog — Position and Size page

OLE Object dialog — Position and Size page

Vertical alignment

The normal default setting for vertical alignment for formulas is to use the text base line as a reference. This default setting can be changed by modifying the frame style for formulas, see the Writer Guide for more information.

  1. Make sure the To paragraph or To character option for formula anchoring is selected to change vertical formula alignment. Vertical alignment is NOT available for the As character anchoring option.

  2. Right-click on the selected formula and select Align Objects from the context menu.

  3. Select a vertical alignment option from the context menu. The options available are Align Top to Anchor, Align Middle to Anchor, and Align Bottom to Anchor.

  4. Alternatively, right-click on the selected formula and select Properties from the context menu, or go to Format > Frame and Object > Properties on the Menu bar to open the Object dialog (Figure 3).

  5. Make sure Position and Size is selected, then select a new vertical alignment from the options available in Position Vertical. The vertical alignment options available are Center, Top, Bottom, or From bottom.

  6. If the From bottom option is selected for vertical alignment, enter a plus or minus value for vertical alignment.

  7. Select the type of text alignment from the drop-down list in Position Vertical. The text alignment options available are Base line, Character, and Row.

  8. Click OK to save the changes and close the OLE Object dialog.

Horizontal alignment

The normal default setting for horizontal alignment for formulas is to use the text base line as a reference. This default setting can be changed by modifying the frame style for formulas, see the Writer Guide for more information.

  1. Right-click on the selected formula and select Align Objects from the context menu.

  2. Select a horizontal alignment option from the context menu. The options available are Left, Centered, and Right.

  3. Alternatively, right-click on the selected formula and select Properties from the context menu, or go to Format > Frame and Object > Properties on the Menu bar to open the Object dialog (Figure 3).

  4. Make sure Position and Size is selected, then select a new horizontal alignment from the options available in Position Horizontal. The horizontal alignment options available are Left, Right, Center, or From left.

  5. If the From left option is selected for horizontal alignment, enter a plus or minus value for horizontal alignment.

  6. Select the type of text alignment from the drop-down list in Position Horizontal. The text alignment options available are Entire paragraph area, Left of paragraph text area, Right of paragraph text area, Left of page text area, Right of page text area, Entire page, Page text area, and Character.

  7. Click OK to save the changes and close the OLE Object dialog.

Object wrap and spacing

A formula, when inserted into a document, has text wrap and spacing on each side of the formula. The default settings used for wrap and spacing is set within the frame style for formulas. This default settings can be changed by modifying the formula frame style, see the Writer Guide for more information.

Object wrap

To individually adjust the wrap for a formula positioned in a Writer document:

  1. Make sure the To paragraph or To character option for formula anchoring is selected to change object wrap. Object wrap is NOT available for the As character anchoring option.

  2. Right-click on the selected formula and select Wrap from the context menu.

  3. Select a wrap option from the context menu. The options available are None, Parallel, Optimal, Before, After, Through In Background and Edit Contour.

  4. Right-click on the selected formula and select Properties in the context menu, or go to Format > Frame and Object > Properties to open the Object dialog.

  5. Click on Wrap to open the Wrap page in the Object dialog (Figure 4).

  6. In Settings, select the type of wrap required for the formula. The options available are Wrap Off, Before, After, Parallel, Through and Optimal.

  7. Click OK to save the changes and close the Object dialog.

Figure 4: OLE Object dialog — Wrap page

OLE Object dialog — Wrap page

Object spacing

To individually adjust the spacing for a formula positioned in a Writer document:

  1. Right-click on the selected formula and select Align Objects from the context menu.

  2. Select a horizontal alignment option from the context menu. The options available are Left, Centered, and Right.

  3. Right-click on the selected formula and select Properties in the context menu, or go to Format > Frame and Object > Properties to open the Object dialog.

  4. Click on Wrap to open the Wrap page in the Object dialog (Figure 4).

  5. In Spacing, enter the spacing value for Left, Right, Top, and Bottom spacing.

  6. Click OK to save the changes and close the Object dialog.

Text mode

When large formulas are placed within a line of text, the formula elements can be higher than the text height. To make large formulas easier to read, it is recommended to always insert large formulas into a separate paragraph to separate a formula from the text.

i=25i2

If it is necessary to place a large formula within a line of text, double-click on the formula to open the Formula Editor and then go to Format > Text Mode on the Menu bar. The Formula Editor reduces the formula size to match text height, as shown in the following example.

The same formula embedded into a line of text using text mode format i=25i2 :

Background and borders

The default setting for background (area fill) and borders for formulas is set by the Formula frame style. For more information on changing the background and borders for Formula frame style, see the Writer Guide. If required, individual formulas in a document can use different backgrounds and borders.

The size of the frame that a formula is placed in when inserted into a document cannot be changed. The frame size for a formula depends on the setting of the formula font size. See Chapter 1, Creating and Editing Formulas for more information.

The following example is a formula using background color and borders. Note that the background and border properties are part of the Math OLE object and cannot be defined using markup language.

df(x)dx=ln(x)+tan1(x2)Δt'=Δt1v2c2

Backgrounds

  1. Select a formula in a document to change the background.

  2. Right-click on the formula and select Properties from the context menu, or go to Format > Frame and Object > Properties on the Menu bar to open the OLE Object dialog.

  3. Click on Area, then select the type of fill required for the formula from the available options (Figure 5). The options available are None, Color, Gradient, Image, Pattern, and Hatch.

Figure 5: OLE Object dialog — Area page

OLE Object dialog — Area page

  1. After selecting the background type, select the properties for the formula background. The area properties change depending on the type of area fill selected.

  2. Click OK to save the changes and close the OLE Object dialog.

Borders

  1. Select a formula in a document to change the borders.

  2. Right-click on the formula and select Properties from the context menu, or go to Format > Frame and Object > Properties on the Menu bar to open the OLE Object dialog.

  3. Click on Borders, then select the of border properties required for the formula from the available options (Figure 6). The options available are Line Arrangement, Line, Padding, and Shadow Type.

  4. Click OK to save the changes and close the OLE Object dialog.

Figure 6: OLE Object dialog — Borders page

OLE Object dialog — Borders page

Quick formula insertion

If the markup language for a formula is available, the formula can be quickly inserted into a document without opening the Formula Editor:

df(x) over dx = ln(x)+tan^-1(x^2) %DELTA t' = { %DELTA t } over sqrt{ 1 - v^2 over c^2 }

df(x)dx=ln(x)+tan1(x2)Δt'=Δt1v2c2

  1. Copy the formula markup language required, then paste into the document at the required position, as shown by the above example.

  2. Select all of the formula markup language.

  3. Go to Insert > OLE Object on the Menu bar and select Formula Object to create a formula using the selected markup language. The formula is inserted replacing formula markup language.

Contents