LibreOffice Logo

Math Guide 25.2

Chapter 1,
Creating and Editing Formulas

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

Math is a formula editor included as a separate LibreOffice module and is used to create or edit formulas (equations), in a symbolic form. These formulas can then be used in LibreOffice documents or as stand-alone objects. An example of the opening window for Math is shown in Figure 1. When using Math, the Elements panel in the Sidebar also opens (Figure 2).

The images used in this document are examples ONLY. Actual images displayed when using Math does depend on computer setup and the computer operating system being used.

When creating formulas in Math, a markup language is used to represent formulas and this markup language is designed to be easily read wherever possible. For example, when the text df(x) over dx = ln(x)+tan^-1(x^2) into the Formula Editor, the following formula appears in the Formula Preview.

df(x)dx=ln(x)+tan1(x2)

Using the Formula Editor in Math, a formula is created as a separate file for insertion into a formula library. Alternatively, formulas can be directly inserted into a document when using Writer, Calc, Impress, or Draw. For more information see the user guides for the specific LibreOffice module being used.

Figure 1: Math opening window

Math opening window

  1. Formula Preview

  1. Formula Editor

  1. Sidebar

Figure 2: Sidebar Elements panel — Relations page

Sidebar Elements panel — Relations page

Formulas in documents or files

Formulas as separate documents or files

As characters are entered the markup language, the formula being created appears in the Formula Preview window during and after input of the markup language, as shown in Figure 1. For more information on creating formulas as a separate document or file, see “Creating formulasbelow.

  1. Use one of the following methods to create a formula as a separate document or file:

  1. When the formula is completed as a new document or file, save the formula in ODF format.

Formulas in LibreOffice documents

A formula can also be created and inserted directly into a Writer, Calc, Draw, or Impress document. An example of creating a formula in a Writer document is shown in Figure 3. The formula box is automatically selected ready for a formula to be entered or edited.

Figure 3: Example of creating a formula in Writer

Example of creating a formula in Writer

Depending on the LibreOffice module being used when inserting a formula, the cursor position changes of where to insert the formula.

Formulas are inserted as OLE objects into documents, as follows:

  1. Go to Insert > OLE Object > Formula Object on the Menu bar to open the Formula Editor.

  2. Alternatively, go to Insert > OLE Object > OLE Object on the Menu bar to open the Insert OLE Object dialog (Figure 4).

  1. Select Create new, then select LibreOffice XX Formula in Object Type.

  2. Click OK to open the Formula Editor.

  1. Create or edit the formula in the Formula Editor.

  2. When the formula has been created or edited, close the Formula Editor using one of the following methods:

Figure 4: Insert OLE Object dialog

Insert OLE Object dialog

For more information on inserting formulas as OLE objects, refer to the following:

Chapter 2, Formulas in Writer

Chapter 3, Formulas in Calc, Draw, and Impress

Writer, Calc, Draw, or Impress Guides.

If formulas are frequently inserted into documents, it is recommended to add Formula Object tool to the Standard toolbar, or create a keyboard shortcut. For more information, see Chapter 4, Customization or the Getting Started Guide.
Using the Elements panel on the Sidebar, or the context menus to create a formula is a convenient way to learn the markup language used used to create formulas.
When using the Elements panel on the Sidebar, it is recommended to have Extended Tips selected in LibreOffice Options. Extended Tips helps in identifying the categories and symbols used in formulas. Go to Tools > Options > LibreOffice > General (macOS LibreOffice > Preferences > LibreOffice > General) on the Menu bar and select Extended Tips in the Help section.

Creating formulas

Formulas are created using one of the following methods:

Elements panel

The Elements panel (Figure 2 above) on the Sidebar is a visual tool for creating and formatting formulas. It organizes mathematical symbols and operators into categories, which are available in a drop-down list for each category.

  1. Select View > Elements on the Menu bar to open the Elements panel in the Sidebar.

  2. Select the category required for the formula from the Categories drop-down list at the top of the Elements panel.

  3. Select the symbol required from the options available in the Elements panel. The available symbols change according to the selected category.

  4. After selecting a symbol, the symbol appears in Formula Preview and the Formula Editor is updated with the markup language used for the selected symbol.

  5. Alternatively, select an example from the Examples list in the Categories drop-down list on the Sidebar (Figure 5).

Figure 5: Sidebar Elements panel — Examples page

Sidebar Elements panel — Examples page

Context menu

The Formula Editor also provides a context menu to access categories and markup language options when creating a formula. An example is shown in Figure 6.

  1. Right-click in the Formula Editor to open the context menu.

  2. Select a category from the options listed in the context menu.

  3. Select a markup language option from the options available in the drop-list.

The Elements panel and the context menu in the Formula Editor provide the most common options and symbols used in formulas. Other options and symbols not listed have to be entered manually using markup language. For a complete list of commands and symbols available in Math, see Appendix A, Commands Reference.

Figure 6: Example of Category Options in Formula Editor

Example of Category Options in Formula Editor

Markup language

Markup language is entered directly into the Formula Editor. For example, typing 5 times 4 into the Formula Editor creates a simple formula. Using markup language is the recommended method for creating formulas. Table 1 shows examples of using markup language to enter commands. For a full list of commands that can be used in the Formula Editor, see Appendix A, Commands Reference.

Table 1: Example commands using markup language

Display

Command

Display

Command

a=b

a = b

a

sqrt {a}

a2

a^2

an

a_n

f(x)dx

int f(x) dx

an

sum a_n

ab

a <= b

infinity

a×b

a times b

xy

x cdot y

Greek characters

Using markup language

Greek characters are commonly used in formulas, but cannot be entered into a formula using the Elements panel in the sidebar, or the context menu in the Formula Editor. Use English names for Greek characters in markup language when entering Greek characters into a formula. See Appendix A, Commands Reference for a list of Greek characters that can be entered using markup language.

Symbols dialog

Greek characters can also be entered into a formula using the Symbols dialog.

  1. Make sure the cursor is at the correct position in the Formula Editor.

  2. Go to Tools > Symbols on the Menu bar, or click Symbols in the Tools toolbar (Figure 7) to open the Symbols dialog.

Figure 7: Tools toolbar

Tools toolbar

  1. Select Greek in the Symbol set drop-down list (Figure 8).

Figure 8: Symbols dialog — Greek

Symbols dialog — Greek

  1. For italic characters, select iGreek in the Symbol drop-down list (Figure 9).

Figure 9: Symbols dialog — iGreek

Symbols dialog — iGreek

  1. Double-click the Greek character required, or select the Greek character and click Insert. When selected, the name of the character is shown below the symbol list.

  2. Click on Close to close the Symbols dialog.

Formula examples

Example 1

A simple formula 5×4  is created in Math as follows:

  1. Make sure the cursor is located and flashing in the Formula Editor.

  2. Enter Multiplication symbol using one of the following methods:

The first two methods above place the formula text <?> times <?> in the Formula Editor and the symbol img_MG25201-010 appears in the document. The third method above, using markup language in the Formula Editor, places the formula directly into the document and it is not necessary to carry out the following steps.

  1. Select the first placeholder <?> before the word times in the Formula Editor and replace with the character 5. The formula in the document updates automatically.

  2. Select the second placeholder <?> after the word times in the Formula Editor and replace it with the character 4. The formula in the document updates automatically.

If necessary, to prevent a formula in a document from updating automatically, go to View on the Menu bar and deselect AutoUpdate Display. The formula can be updated manually when necessary. Press the F9 key or select View > Update on the Menu bar.

Example 2

The formula for Pi π3.14159  where value is rounded to 5 decimal places is created as follows. The Greek character (pi) is known, but the required markup language Similar Or Equal symbol  is not known.

  1. Make sure the cursor is located and flashing in the Formula Editor.

  2. Enter %pi in the Formula Editor to create the Greek character for Pi (π).

  3. Select the category Relations, then select the symbol Is Similar Or Equal using one of the following methods:

  1. Delete the first placeholder symbol <?> before the word simeq in the Formula Editor.

  2. Select the second placeholder symbol <?> after the word simeq in the Formula Editor and enter 3.14159 to delete the second placeholder symbol. The formula now appears in the document.

Editing formulas

How a formula is edited and opening formula editing mode depends on whether the formula is in Math or another LibreOffice module.

  1. To select the formula and open Formula Editor using one of the following methods:

If a formula element cannot be selected using the cursor, click on Formula Cursor in the Tools toolbar (Figure 7 above) to activate the formula cursor.

  1. Select the formula element to be changed using one of the following methods:

  1. Make all necessary changes to the selected formula element.

  2. Go to View > Update on the Menu bar, press the F9 key, or click on Update on the Tools toolbar to update the formula.

  3. Save the changes to the formula using one of the following methods:

Formula layout

Using braces

Math knows does not use order of operation within a formula. Braces (curly brackets) have to be used to define the order of formula operations. The following examples show how braces are used in a formula.

Example 1

2 over x + 1 creates the formula 2x+1

Math recognized the 2 before and the x after the over command belong to a fraction and has represented them accordingly. If x+1 is required rather than x to be a denominator, x+1 must be bracketed together using braces to create the correct formula. Inserting braces as shown in

 2 over {x + 1} creates the correct result where x+1 now the denominator: 2x+1

Example 2

– 1 over 2 creates the formula 12

Math has recognized the minus sign as a prefix for the 1 and has placed it as the numerator of the fraction. If it is required that the whole fraction is negative with the minus sign in front of the fraction, the fraction must be placed in braces to instruct Math that all the characters are part of the whole fraction. Adding braces into the markup language

– {1 over 2} creates the whole fraction negative 12

Example 3

Braces are used in markup language to define the formula layout and are not displayed or printed. If braces used within a formula are to be printed, use the commands lbrace and rbrace within the markup language.

x over {–x + 1} gives the formula xx+1

Replace the braces with lbrace and rbrace in the markup language as follows:

x over lbrace –x + 1 rbrace creates the formula x{x+1}

Brackets (parentheses) and matrices

To use a matrix in a formula, the matrix command has to be used.

Example 1

To create a simple example of a 2x2 matrix. In matrices, rows are separated by two hashes (##) and entries within each row are separated by one hash (#).

( matrix { a # b ## c # d } (abcd)

Example 2

Normally, when brackets are used within a matrix, the brackets do not scale as the matrix increases in size. The following example shows a formula where the parentheses do not scale to the size of the resulting matrix.

( matrix { a # b ## c # d } ) (abcd)

Example 3

To solve this problem, Math provides scalable brackets that change in size to match the matrix size. The commands left( and right) have to be used to create scalable brackets around a matrix. The following example shows how to create a matrix with scalable parentheses.

left( matrix { a # b ## c # d } right) (abcd)

Scalable brackets can be used with any formula element, such as fraction, square root, and so on.

To create a matrix where some values are empty, the grave accent (`) is used so that Math places a small space in the position where grave accent (`) has been placed, as shown in the following example:

left( matrix { 1 # 2 # 3 ## 4 # ` # 6 } right) (12346)

Use the commands left[ and right] to obtain square brackets. A list of all brackets available within Math can be found in Appendix A, Commands Reference.
If all brackets are to be scalable, go to Format > Spacing on the Menu bar to open the Spacing dialog. Click on Category and select Brackets from the drop-down list, then select the option Scale all brackets from the drop-down list.

Unpaired brackets

When using brackets in a formula, Math expects that for every opening bracket there will be a closing bracket. If a closing bracket is not used, Math places an inverted question mark next to where the closing bracket should have been placed.

For example, lbrace a; b creates  because the right bracket rbrace is missing. This inverted question mark disappears when all brackets are paired. This is corrected by using lbrace a; b rbrace, which creates {a;b} . However, there are cases where an unpaired bracket is required.

Non scalable brackets

A backslash \ is placed before a non scalable bracket to indicate that the subsequent character is not a bracket, but a literal character.

Example

The unpaired brackets in the formula [ a; b [ results in an inverted question mark being entered because Math expects that [ will be closed by ]. To correct the error, use a backslash for every bracket into the Formula Editor.

\ [ a; b \ [ creates the formula [a;b[ .

Scalable brackets

To create unpaired scalable brackets or braces in a formula, the markup commands left, right, and none are used.

Example

The following formula uses the stack command to create a two-line formula and adds a bracket only to the right side of the stack. This effect is achieved by using the left lbrace command combined with the right none command. The first command indicates that the left bracket is a lbrace and the second command none tells Math that there is no right bracket added to the right side of the formula.

abs x = left lbrace stack {x "for" x >= 0 # -x "for" x < 0} right none

|x|={xforx0xforx<0

Recognizing functions

In the normal installation of Math, Math creates functions using normal characters and variables in italic characters. However, if Math fails to recognize a function, Math can be forced to recognize that a function has been entered. Using the markup command func before a function forces Math to recognize following text as a function.

For a full list of functions available in Math, see Appendix A, Commands Reference.

Some Math functions have to be followed by a number or variable. If a number or variable is missing, Math places an inverted question mark where the missing number or variable should be. To remove the inverted question mark and correct the formula, enter a number, variable, or pair of empty brackets as a placeholder.

Navigate through formula errors using the function key F3 to move to the next error, or use the function key combination Shift+F3 to move to the previous error.

Multiple line formulas

When creating a formula that requires more than one line, for example x=3y=1 , the first reaction is to use the Enter key. However, when the Enter key is used, the markup language in the Formula Editor goes to a new line, but the resulting formula does not have two lines. To add a new line into a formula, the markup command newline has to be used

Table 2 shows how the markup command newline is used to add a new line to a formula. The first example simply adds an Enter command to break the line in the markup language. This does not create a new line in the formula. The second example uses the newline command. The newline command creates a two-line formula.

Table 2: Examples of multiple line formulas

Markup Language

Resulting Formula

x = 3
y = 1

x=3y=1

x = 3 newline y = 1

x=3y=1

It is not possible in Math to create multiple line formulas when a line ends with an equals sign and continue the formula on a new line. A term on the right side of the equals sign must be entered to create multiple line formulas.

If a multiple line formula is required to have an equals sign at the end of a line without a term after the equals sign, use empty quotes “”, empty braces {}, grave character `, or tilde character ˜.

By default, the alignment of a multiple line formula is center aligned. For more information on alignment using the equals sign, see “Aligning formulas using equals signbelow.

Formula element spacing

Spacing between elements in a formula is not set by using space characters in the markup language. To add spaces into a formula, use one of the following options:

Any spaces at the end of a line in the markup language are ignored by default. For more information, see Chapter 4, Customization.

Adding limits to summations and integrals

The sum and int commands are used for summations and integrals with the parameters from and to used to set the lower and upper limits. The parameters from and to can be used singly or together as shown by the following examples. For more information on the sum and int commands, see Appendix A, Commands Reference.

Table 3 shows how to add upper and lower bounds to summations and integrals. Note that brackets are used to define which parts of the formula correspond to the desired bounds.

Table 3: Example of using summations and integrals

Markup Language

Resulting Formula

sum from k = 1 to n a_k

k=1nak

sum to infinity 2^{-n}

2n

sum from{ i=1 } to{ n } sum from{ j=1; i <> j } to{ m } x_ij

i=1nj=1;ijmxij

int from 0 to x f(t) dt

0xf(t)dt

int_0^x f(t) dt

0xf(t)dt

 int from Re f

f

Adding derivatives

When adding derivatives to a formula, indicate in Math that it is a fraction by using the over command. The over command is combined with the character d for a total derivative, or the partial command for a partial derivative to achieve the effect of a derivative. Braces {} are used on each side of elements to enclose the elements and make the derivative as shown in Table 4.

Table 4: Examples of adding derivatives

Markup Language

Resulting Formula

{df} over {dx}

dfdx

{partial f} over {partial y}

fy

{partial^2 f} over {partial t^2}

2ft2

To write function names with primes, as is normal in school notation, add the symbols to the catalog first. For more information, see Chapter 4, Customization.

Markup language characters as normal characters

Characters that are used as controls in markup language cannot be entered directly as normal characters. Control characters are: %, {, }, &, |, _, ^ and ". For example, 2% = 0.02 cannot be entered into markup language and expect the same characters to appear in a formula. To overcome this limitation in markup language, use one of the following methods:

The Special Characters dialog used by other LibreOffice modules is not available in Math. If special characters are required in Math, then it is recommended to add the characters to the Math Catalog. See Chapter 4, Customization for more information.

Text in formulas

To include text in a formula, enclose any text in double-quotes, for example x " for " x >= 0 in markup language creates the formula x for x0 . All characters, except double quotes, can be used in text.

However, if double quotes are required in formula text, any text text created in Writer must be contained within typographic double quotes. The text is then copied and pasted as the text into the Formula Editor as shown in Figure 10.

Figure 10: Example of using double quotes to create formula text

Example of using double quotes to create formula text

Formatting text in formulas

Formatting commands are not interpreted within text used in formulas. To use formatting commands within formula text, the text flow must be broken by using double quotes in the Formula Editor.

Example

Enter the following text in the Formula Editor using markup language to create text in a formula:

"In " color blue bold "isosceles" "triangles, the base angles are equal"

In isoscelestriangles, the base angles are equal

The example above shows how markup language is used to change the text color to blue and use bold text for the word “isosceles” in the formula. Note that the commands are applied to any text placed between the double quotes. The formatting command color blue bold is not applied to the rest of the text in the example because it is a separate quote block.

Aligning formulas using equals sign

Math does not have a command for aligning formulas on a character. However, a matrix can be used to align formulas on the equals sign (=) character. The markup commands alignr, alignl and alignc are used to align each value inside a matrix to the right, left or center, respectively.

Example

The following uses a matrix to align formulas on the equals sign and uses alignment commands to align the contents of each position within the matrix. The spacing on each side of the equals sign cab be reduced if the inter-column spacing of the matrix is adjusted. See “Adjusting formula spacingbelow for more information.

matrix{ alignr x+y # {}={} # alignl 2 ## alignr x # {}={} # alignl 2-y }

x+y=2x=2y

The empty braces each side of the equals sign are required. The equals sign is a binary operator and requires an expression on each side. Spaces, or characters ` or ~ on each side of the equals sign can be used, but it is recommended to use braces because braces are easier to see within markup language.

Changing formula appearance

Only the default font or font size can be changed in a formula. Any formulas that were already inserted into a document will continue to use the previous settings for default font and font size. The font and font size of these previously inserted formulas have to be changed individually to use the new setting for default font and font size.

The extension Formatting of All Math Formulas can be used to change font name and font size for all or selected formulas in a document. The extension and instructions for use can be downloaded from the LibreOffice website using the following link: https://extensions.libreoffice.org/en/extensions/show/formatting-of-all-math-formulas.

Formula font size

Changing formula font size

To change the font size used in a formula already inserted into a LibreOffice document:

  1. Click in the markup language in the Formula Editor.

  2. Go to Format > Font size on the Menu bar to open the Font Sizes dialog (Figure 11).

Figure 11: Font Sizes dialog

Font Sizes dialog

  1. Select a different font size from the options available in Base size, or enter a new font size in the text box.

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

Example

Default font size 12pt: π3.14159

Font size changed to 18pt: π3.14159

Default formula font size

To change the default font size used for all formulas in a LibreOffice document:

  1. Before inserting any formulas into a document, go to Format > Font size on the Menu bar to open the Font Sizes dialog (Figure 11).

  2. Select a different font size from the options available in Base size, or enter a new font size in the text box.

  3. Click on Default and select Yes in the conformation dialog that opens to save the change in font size.

  4. Click on OK to save the changes and close the Font Sizes dialog. Any new formulas created will use the new base size font for formulas.

Font size options

The Font Sizes dialog ((Figure 11) specifies the font sizes used in a formula. Change the base size and all elements in the formula created after the change will use the new base font size.

Base size

All elements of a formula are proportionally scaled to the base size. To change the base size, select or type in the desired point (pt) size. You can also use other units of measure or other metrics, which are then automatically converted to points.

Relative Sizes

Determines the relative sizes for each type of element with reference to the base size.

Text

Select the text size in a formula relative to the base size.

Indexes

Select the relative size for indexes in a formula in proportion to the base size.

Functions

Select the relative size for names and function elements in a formula in proportion to the base size.

Operators

Select the relative size of the mathematical operators used in a formula in proportion to the base size.

Limits

Select the relative size for the limits in a formula in proportion to the base size. This is used to determine the size for commands from and to used in summations and integrals.

Default

Select Default to save any changes to the font size options. The new font sizes are then used as default for all new formulas.

Formula fonts

Changing formula fonts

To change the fonts used for a formula in a LibreOffice document:

  1. Click in the markup language in the Formula Editor.

  2. Go to Format > Fonts on the Menu bar to open the Fonts dialog (Figure 12).

Figure 12: Fonts dialog

Fonts dialog

  1. Select a new font for each of the various options in the drop-down lists in the Fonts dialog.

  2. If the font required does not appear in the drop-down list, click Modify and select the option from the context menu to open a fonts dialog.

  3. Select the font required and click OK to add the font to the drop-down list for the selected option.

  4. Click OK to save the changes and close the Fonts dialog.

Default formula fonts

To change the default fonts used for all formulas in a LibreOffice document:

  1. Before inserting any formulas into a document, go to Format > Font size on the Menu bar to open the Fonts dialog (Figure 12).

  2. Select a new font for each the various options from the drop-down lists.

  3. If the font required does not appear in the drop-down list, select Modify and then select an option from the context menu to open a fonts dialog.

  4. Select the font required and click OK to add the new font to the drop-down list for the selected option.

  5. Click on Default and select Yes in the conformation dialog that opens to save the change in font type.

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

Formula font options

Formula Fonts

Defines the fonts used for the variables, functions, numbers and inserted text used for formula elements.

Variables

Selects the fonts used for the variables in a formula.

Functions

Selects the fonts used for the function names and properties.

Numbers

Selects the fonts for the numbers in a formula.

Text

Defines the font used for text in a formula.

Custom Fonts

Defines fonts to format text components in a formula. The three basic fonts Serif, Sans‑serif and Fixed-width are available. Other fonts can be added using the Modify option. All fonts installed on a computer system are available for use.

Serif

Specifies the font used for a serif font format.

Sans

Specifies the font used for a sans font format.

Fixed

Specifies the font used for a fixed font format.

Modify

Select an option from the context menu to access the Fonts dialog to define the font and font attributes for a formula and for any custom fonts being used.

Default

Click on Default to save any changes as the default for all new formulas. A confirmation message appears before any changes are saved.

When a new font is used for a formula, the old font remains available and can be selected again.
Variables are written in italics. For all other formula elements, the basic font form is used. The font style can be altered in the formula by using the commands italic or bold. To stop using an italic or bold font, use nitalic or nbold after the variable

Adjusting formula spacing

The alignment settings determine how formula elements located above one another are aligned horizontally relative to each other.

Current formula spacing

To change the spacing used in the current formula in a LibreOffice document:

  1. Click in the markup language in the Formula Editor.

  2. Go to Format > Spacing on the Menu bar to open the Spacing dialog (Figure 13).

  3. Click Category and select one of the options from the drop-down list. The options in the Spacing dialog change depending on which category is selected.

  4. Enter new values for the spacing category and click OK.

  5. Check the spacing format in the formula. If the spacing format is not correct, repeat the steps above.

Default formula spacing

To change the default spacing used for all formulas in a LibreOffice document:

  1. Before inserting any formulas into a document, go to Format > Spacing on the Menu bar to open the Spacing dialog (Figure 13).

  2. Click Category and select one of the options from the drop-down list. The options in the Spacing dialog change according to the category selected.

  3. Make the required changes to the category option, then click Default and confirm the changes to the formula spacing. Any new formulas created will use the new spacing for formulas.

  4. Click OK to save the changes and close the Spacing dialog.

Figure 13: Spacing dialog

Spacing dialog

Only new formulas inserted after the change in formula spacing will use the new setting for formula spacing. For any formulas inserted into a document before the default spacing was changed, the new default spacing will not be applied. The formula spacing on each formula already inserted into a document will have to be changed manually.

Formula spacing options

Use the Category options available in the Spacing dialog (Figure 13) to change the spacing for a formula element. The dialog that opens depends on the selected category. A preview window displays which spacing is being changed.

Category

Select a category to change the formula spacing.

Spacing

Defines the spacing between variables and operators, lines, and root signs and radicals.

Spacing

Determines the spacing between variables and operators

Line Spacing

Determines the spacing between lines.

Root Spacing

Determines the spacing between the root sign and radicals.

Indexes

Defines the spacing for superscript and subscript indexes.

Superscript

Determines the spacing for superscript indexes.

Subscript

Determines the spacing for subscript indexes.

Fractions

Defines the spacing between the fraction bar and the numerator or denominator.

Numerator

Determines the spacing between the fraction bar and the numerator.

Denominator

Determines the spacing between the fraction bar and the denominator.

Fraction Bars

Defines the excess length and line weight of the fraction bar.

Excess length

Determines the excess length of the fraction line.

Weight

Determines the weight of the fraction line.

Limits

Defines the spacing between the sum symbol and the limit conditions.

Upper limit

Determines the spacing between the sum symbol and the upper limit.

Lower limit

Determines the spacing between the sum symbol and the lower limit.

Brackets

Defines the spacing between brackets and the content.

Excess size (left/right)

Determines the vertical distance between the upper edge of the contents and the upper end of the brackets.

Spacing

Determines the horizontal distance between the contents and the upper end of the brackets.

Scale all brackets

Scales all types of brackets. If ( a over b) is entered into the Formula Editor, the brackets surrounds the whole height of the argument.

Excess size

Adjusts the percentage excess size. At 0% the brackets are set so that they surround the argument at the same height. The higher the value that is entered, the larger the vertical gap between the contents of the brackets and the external border of the brackets. The option can only be used in combination with Scale all brackets.

Matrices

Defines the relative spacing for the elements in a matrix.

Line spacing

Determines the spacing between matrix elements in a row.

Column spacing

Determines the spacing between matrix elements in a column.

Symbols

Defines the spacing of symbols in relation to variables

Primary height

Defines the height of the symbols in relation to the baseline.

Minimum spacing

Determines the minimum distance between a symbol and variable.

Operators

Defines the spacing between operators and variables or numbers.

Excess size

Determines the height from the variable to the operator upper edge.

Spacing

Determines the horizontal distance between operators and variables.

Borders

Adds a border to a formula. This option is particularly useful if you want to integrate the formula into a text file in LibreOffice Writer by combining mathematical formulas and text inside the same paragraph.

Left

The left border is positioned between the formula and background.

Right

The right border is positioned between the formula and background.

Top

The top border is positioned between the formula and background.

Bottom

The bottom border is positioned between the formula and background.

Preview Field

Displays a preview of the current selection.

Default

Saves any changes as default settings for all new formulas. A security response will appear before saving these changes.

When adding formulas into a LibreOffice document, there may be spacing between the formula and surrounding text, even if all formula borders are set to zero. This is because formulas are OLE objects embedded into a frame that, by default, adds 0.2 cm to the left and right of the formula.
Extra spacing can be removed using one of two methods. First method is to edit the object properties by right-clicking the formula and then going to Properties > Wrap to adjust the Spacing fields to the required values. The second method is to change the spacing options for the formula frame style or create a new style. For more information on changing the formula spacing, see Chapter 2, Formulas in Writer. For more information on how to edit styles in general, see the Writer Guide.

Example

Math objects are combined with text by removing all spacing both from the formula and the frame style surrounding it. Because spacing is set to zero, the spacing between text and formulas is achieved by simply adding a space character using the keyboard space bar.

“Let cij  be a cost matrix and xij{0;1}  be a decision variable defined for i=1,2,...,m  origins and for j=1,2,...,n  destinations”.

Adjusting formula alignment

The formula alignment is used for determining how formula elements are located above one another and aligned horizontally relative to each formula element.

It is not possible to align formulas on a character and formula alignment cannot be used to align text elements. Text elements are always aligned to the left.
It is possible to align sections of a formula using the commands alignl, alignc and alignr. Using these commands, matrices and text elements in a formula can be aligned.

Current formula alignment

To change the alignment used for a formula in a LibreOffice document:

  1. Click in the markup language in the Formula Editor.

  2. Go to Format > Alignment on the Menu bar to open the Alignment dialog (Figure 14).

  3. Select Left, Centered, or Right for horizontal alignment.

Figure 14: Alignment dialog

Alignment dialog

  1. Select OK and check the result in the Formula Preview. If necessary, repeat steps 1 to 3 to correct the formula alignment.

Default formula alignment

To change the default alignment used for all formulas in a LibreOffice document:

  1. Click in the markup language in the Formula Editor.

  2. Go to Format > Alignment on the Menu bar to open the Alignment dialog (Figure 14).

  3. Select Left, Centered, or Right for horizontal alignment.

  4. Select Default and confirm the changes to the formula alignment. Any new formulas created will use the new formula alignment.

  5. Select OK and check the result in the Formula Preview. If necessary, repeat steps 1 to 4 to correct the formula alignment.

Only formulas inserted after changing in formula alignment use the new default settings. For any formulas already inserted into a document before the default alignment was changed, the new default alignment is not applied. The formula alignment on each formula already inserted into a document has to be changed manually.

Changing formula color

The color of formula characters can be changed using markup language. Use the command color followed by a color name, RGB value, or HTML hex value.

Named colors

For information on the named colors available in Math, see Appendix A. These colors are listed in the Attributes category of the Elements panel on the Sidebar (Figure 2 above).

RGB values

RGB (Red, Green and Blue) values for colors are from 0 to 255. To use RGB values, enter the command color rgb R G B followed by the RGB values of the required color.

Example

In this example, the formula element decision variable uses a color defined with the RGB values of 160, 82, 45.

"Let " x_ij " be a " color rgb 160 82 45 "decision variable " " in the problem under consideration"

Creates the following in a formula:

Let xij be a decision variable in the problem under consideration

Hex values

HTML colors can be used in a formula and these are defined using a hex number. Use the command hex 000000, where 00000 is the corresponding hex number for the color required. For example, using the command color hex FF0000 decision creates the output decision .

Background color

It is not possible to use a background color for formulas. The formula background color is, by default, the same color as the document or frame where the formula has been inserted. In Writer, object properties can be used to change the background color of a formula. For more information, see Chapter 2, Formulas in Writer.

Formula library

If formulas are going to be regularly inserted documents, a formula library can be created using the Formula Editor. Individual formulas are saved as separate files using the ODF format file type ODF, or the MathML format for file type MML. Math, Writer, Calc, Draw, or Impress can be used to create formulas and added to a formula library.

MathML 2.0 stands for Mathematical Markup Language (MathML) Version 2.0. MathML is an XML format that describes mathematical notation and enables the use of mathematics in the World Wide Web. For more information on MathML format, visit the website at https://www.w3.org/TR/MathML2/overview.html.

Using Math

  1. Create a computer folder to contain formula files and give the folder a memorable name, for example Formula Library.

  2. Go to File > New > Formula on the Menu bar, or click on Math Formula in the Start Center to open LibreOffice Math and the Formula Editor. See “Formulas as separate documents or filesabove for more information.

  3. Create the formula required.

  4. Go to File > Save As on the main Menu bar, or use the keyboard shortcut Ctrl+Shift+S (macOS ⌘+Shift+S) to open the Save As dialog.

  5. Navigate to the folder created for a formula library.

  6. Type a memorable name for the formula in the file name or save as box.

  7. Select in the File type drop-down list select ODF Formula (.odf) or MathML 2.0 (.mml) as the file type for the formula.

  8. Click Save to save the formula and close the Save As dialog.

Using Writer, Calc, Draw, or Impress

  1. Create a computer folder to contain formula files and give the folder a memorable name, for example Formula Library.

  2. Open a document using Writer, Calc, Draw, or Impress.

  3. Go to Insert > Object > Formula Object on the Menu bar to open the Formula Editor and create a formula. See “Formulas in LibreOffice documentsabove for more information.

  4. Right-click on the formula object and select Save Copy as in the context menu to open a Save As dialog.

  5. Navigate to the folder you have created for your formula library.

  6. Type a memorable name for your formula in the File name box.

  7. Select in the File type drop-down list either ODF Formula (.odf) or MathML 2.0 (.mml) as the file type for the formula.

  8. Click Save to save the formula and close the Save As dialog.

Using a formula library

A formula in the formula library cannot be inserted into a document by dragging and dropping, or by using Insert > File on the Menu bar. A formula from the formula library must be inserted into a document as an OLE object.

  1. Open a document using Writer, Calc, Draw, or Impress.

  2. Go to Insert > OLE Object > OLE Object on the Menu bar to open the Insert OLE Object dialog (Figure 15).

  3. Select the option Create from file.

  4. Click Search to open the file browser and navigate to the formula library folder.

Figure 15: Insert OLE Object dialog — Create from file page

Insert OLE Object dialog — Create from file page

  1. Select the file for formula required and click Open in the file browser, or double-click on the formula required.

 If required, select the option Link to file or Display as icon.

Click OK to insert the formula as an OLE object in the document and close the Insert OLE Object dialog.

Contents