Getting Started Guide
 

Chapter 9  
Getting Started with Math

LibreOffice’s Formula (Equation) Editor

Copyright

This document is Copyright © 2017 by the LibreOffice Documentation Team. Contributors are listed below. You may distribute it and/or modify it under the terms of either the GNU General Public License (http://www.gnu.org/licenses/gpl.html), version 3 or later, or the Creative Commons Attribution License (http://creativecommons.org/licenses/by/4.0/), version 4.0 or later.

All trademarks within this guide belong to their legitimate owners.

Contributors

Jean Hollis Weber

Hazel Russman

Laurent Balland-Poirier

John A Smith

Martin Saffron

Peter Schofield

Olivier Hallot

 

 

Feedback

Please direct any comments or suggestions about this document to the Documentation Team’s mailing list: documentation@global.libreoffice.org

Note: Everything you send to a mailing list, including your email address and any other personal information that is written in the message, is publicly archived and cannot be deleted.

Acknowledgments

This chapter is based on the OpenOffice.org 3.3 Math Guide. The contributors to that book are:

Daniel Carrera

Agnes Belzunce

TJ Frazier

Peter Kupfer

Ian Laurenson

Janet M. Swisher

Jean Hollis Weber

Michele Zarri

 

Additional material has been added from the German Math Handbuch for LibreOffice 3.4 (translated to English by Hazel Russman). Contributors to that book are:

Regina Henschel

Christian Kühl

Florian Reisinger

Gisbert Friege (Dmaths)

Jochen Schiffers

 

Additional material has been added from the French How-To Math for LibreOffice (translated to English by Laurent Balland-Poirier). Contributors to that book are Bernard Siaud and Frédéric Parrenin.

Publication date and software version

Published 16 February 2017. Based on LibreOffice 5.2.

Note for Mac users

Some keystrokes and menu items are different on a Mac from those used in Windows and Linux. The table below gives some common substitutions for the instructions in this chapter. For a more detailed list, see the application Help.

Windows or Linux

Mac equivalent

Effect

Tools > Options menu selection

LibreOffice > Preferences

Access setup options

Right-click

Control+click or right-click depending on computer setup

Opens a context menu

Ctrl (Control)

⌘ (Command)

Used with other keys

F5

Shift+⌘+F5

Open the Navigator

F11

⌘+T

Open the Styles and Formatting window

 

Contents

Copyright

Contributors

Feedback

Acknowledgments

Publication date and software version

Note for Mac users

Introduction

Getting started

Formulas as separate documents or files

File formats for formulas

Formulas in LibreOffice documents

Creating formulas

Elements window

Context menu

Markup language

Greek characters

Using markup language

Symbols dialog

Formula examples

Example 1

Example 2

Editing formulas

Formula layout

Using braces

Brackets and matrices

Unpaired brackets

Non-scalable brackets

Scalable brackets

Recognizing functions

Formulas over multiple lines

Adding limits to sum/integral commands

Writing derivatives

Markup language characters as normal characters

Text in formulas

Aligning formulas using equals sign

Changing formula appearance

Formula font size

Current formula font size

Default formula font size

Formula fonts

Current formula fonts

Default formula fonts

Adjusting formula spacing

Current formula spacing

Default formula spacing

Adjusting formula alignment

Current formula alignment

Default formula alignment

Changing formula color

Character color

Background color

Formula library

Using Math

Using Writer, Calc, Draw, or Impress

Using your formula library

Formulas in Writer

Automatic formula numbering

Numbering

Cross-referencing

Anchoring formulas

Vertical alignment

Object spacing

Text mode

Background and borders

Backgrounds

Borders

Quick insertion of formulas

Formulas in Calc, Draw, and Impress

Anchoring formulas

Calc

Draw and Impress

Formula object properties

Formulas in charts

 

Introduction

LibreOfficeMath is a formula editor you can use to create or edit formulas (equations) in a symbolic form within LibreOffice documents or as standalone objects. Example formulas are shown below. However, if you want to evaluate numeric values using formulas, then refer to the Calc Guide for more information; Math does not carry out any actual calculation.

df ( x ) dx = ln ( x ) + tan 1 ( x 2 )
or
NH 3 + H 2 O NH 4 + + OH
 
The Formula Editor in Math uses a markup language to represent formulas. This markup language is designed to be easily read wherever possible, for example, a over b produces the fraction a b when used in a formula.

Getting started

Using the Formula Editor, you can create a formula as a separate document or file for a formula library, or insert formulas directly into a document using LibreOffice Writer, Calc, Impress, or Draw.

Formulas as separate documents or files

 

Figure 1: An empty formula document in Math

 

To create a formula as a separate document or file, use one of the following methods to open an empty formula document in LibreOffice Math (Figure 1):

As you enter the markup language in the Formula Editor, the formula will appear in the Preview window during and after input of the markup. The Elements window to the left of the Preview window may also appear, if it has been selected in View on the menu bar. For more information on creating formulas, see “Creating formulas” on page 7.

File formats for formulas

LibreOffice’s native file format for formulas is ODF Formula, with extension *.odf. You can also embed formula objects in other documents like presentations, spreadsheets, or text documents. LibreOffice can also read and save formulas in MathML 1.01 format, with extension .mml.

LibreOffice Math can import MathML Presentations directly from the clipboard. To import a MathML Presentation formula, copy the formula from the external equation editor and issue Tools > Import MathML from Clipboard. For example, the MathML code on the left of Table 1 displays the equation on the right.

Table 1: MathML 1.01 language imported from the clipboard

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">

 <semantics>

  <mrow>

   <mi>E</mi>

   <mo stretchy="false">=</mo>

   <msup>

    <mi mathvariant="italic">mc</mi>

    <mn>2</mn>

   </msup>

  </mrow>

 </semantics>

</math>

E = mc 2
 

Formulas in LibreOffice documents

To insert a formula into a LibreOffice document, open the document in Writer, Calc, Draw, or Impress. The LibreOffice module in use affects how you position the cursor to insert the formula.

Then, go to Insert > Object > Formula on the menu bar to open the Formula Editor. Alternatively, go to Insert > Object > OLE Object on the menu bar to open the Insert OLE Object dialog, select Create new option and Formula from the sub-menu, then click OK to open the Formula Editor. The Elements window to the left of the Preview window may also appear, if it has been selected in View on the menu bar. For more information on creating formulas, see “Creating formulas” on page 7.

Figure 2 shows an example Writer document with the formula box selected ready for a formula to be entered.

When you have completed entering the markup for the formula, close the Formula Editor by pressing the Esc key or by clicking an area outside the formula in the document. Double-clicking on the formula object in the document will open the Formula Editor again so that you can edit the formula.

Formulas are inserted as OLE objects into documents. As with any OLE object, you can change how the object is placed within the document. For more information on OLE objects, see the user guides for Math, Writer, Calc, Draw, and Impress.

 

 

Figure 2: Empty formula in a Writer document

 

If you frequently insert formulas into documents, you might like to add the Formula button to the Standard toolbar or create a keyboard shortcut. See Chapter 14, Customizing LibreOffice, for more information.

Creating formulas

You can insert elements into a formula using one of the following methods:

Using the Elements window or the context menus to insert a formula provides a convenient way to learn the markup language used by LibreOffice Math.

Elements window

The Elements window can easily be used when entering formula data. In addition to the list of categories at the top of the window, it also provides an Example category with example formulas to use as a starting point for a formula or equation.

  1. 1)  Go to View on the menu bar and select Elements to open the Elements window. 

  2. 2)  Select the category you want to use in the formula from the drop-down list at the top of the Elements window. 

  3. 3)  Select the symbol you want to use in the formula from the Elements window. The symbols that are available change according to the selected category. 

The Elements window is positioned by default to the left of the Preview and Formula Editor windows, as shown in Figure 1 and Figure 2. It can be floated in the same way as other docked windows.

Context menu

The Formula Editor also provides a context menu to access categories and symbols when creating a formula. Right-click in the Formula Editor to open the context menu. Select a category and then select the markup example that you want to use from the sub-context menu. An example is shown in Figure 3.

 

Figure 3: Context menu in Formula Editor

 

The Elements window and the context menu contain only the most common commands that are used in formulas. For some seldom-used commands, you must always enter the command using the markup language. For a complete list of commands, see the Math Guide.

Markup language

Markup language is entered directly into the Formula Editor. For example, typing the markup 5 times 4 into the Formula Editor creates the simple formula 5 × 4 . If you are experienced in using markup language, it can be the quickest way to enter a formula. Table 2 shows some examples of using markup language to enter commands. For a full list of commands that can be used in the Formula Editor, see the Math Guide.

Table 2: Example commands using markup language

Display

Command

Display

Command

a = b
 

a = b

a
 

sqrt {a}

a 2
 

a^2

a n
 

a_n

f ( x ) dx
 

int f(x) dx

a n
 

sum a_n

a b
 

a <= b

 

infinity

a × b
 

a times b

x y
 

x cdot y

Greek characters

Using markup language

Greek characters are commonly used in formulas, but Greek characters cannot be entered into a formula using the Elements window or the context menu. Use the English names of Greek characters in markup language when entering Greek characters into a formula. See Appendix A, Commands Reference, in the Math Guide 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. 1)  Make sure the cursor is in the correct position in the Formula Editor. 

  2. 2)  Go to Tools > Symbols on the menu bar or click on the Symbols icon on the Tools toolbar to open the Symbols dialog (Figure 4). 

  3. 3)  Select Greek from the Symbol set drop-down list. For italic characters, select iGreek from the drop-down list. 

  4. 4)  Select the Greek character from the symbol list, then click Insert. When selected, the name of a Greek character is shown below the symbol list. 

  5. 5)  Click Close when you have finished entering Greek characters into the formula. 

 

Figure 4: Symbols dialog

 

Formula examples

Example 1

The simple formula 5 × 4
can be created using LibreOffice Math as follows:
 
  1. 1)  Make sure the cursor is flashing in the Formula Editor, then select the category Unary/Binary Operators and symbol Multiplication using one of the following methods: 

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

  2. 3)  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. 

This method initially places the formula text <?> times <?> in the Formula Editor and the symbol appears in the document. These placeholders must then be replaced with real numbers. Using markup language in the Formula Editor places the formula 5 × 4 directly into the document. To use markup language, enter 5 times 4 in the Formula Editor. 5 × 4
appears in the document.
 

To move forward from one placeholder to the next placeholder in a formula, press the F4 key. To move backward from one placeholder to the previous placeholder in a formula, use the key combination Shift+F4.

If necessary, you can prevent a formula in a document from updating automatically. Go to View on the menu bar and deselect AutoUpdate display. To then manually update a formula, press F9 key or select View > Update on the menu bar.

Example 2

You want to enter the formula π 3.14159
where the value of pi is rounded to 5 decimal places. You know the name of the Greek character (pi), but do not know the markup associated with the Is Similar Or Equal symbol .
 
  1. 1)  Make sure the cursor is flashing in the Formula Editor. 

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

  3. 3)  Select the category Relations and symbol Is Similar Or Equal using one of the following methods: 

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

  2. 5)  Select the second placeholder <?> after the word simeq in the Formula Editor and replace it with the characters 3.14159. The formula π 3.14159 now appears in the document. 

Editing formulas

How you edit a formula and switch into formula editing mode depends on whether the formula is in Math or another LibreOffice component.

  1. 1)  In Math, double-click on a formula element in the formula that appears in the Preview window to select the formula element in the Formula Editor, or directly select a formula element in the Formula Editor. 

  2. 2)  In Writer, Calc, Impress, or Draw, double-click on the formula, or right-click on the formula and select Edit from the context menu, to open the Formula Editor in editing mode. The cursor is positioned at the start of the formula in the Formula Editor. 

If you cannot select a formula element using the cursor, click on the Formula Cursor icon in the Tools toolbar to activate the formula cursor.
  1. 3)  Select the formula element you want to change, using one of the following methods: 

  1. 4)  Make your changes to the selected formula element. 

  2. 5)  Go to View > Update on the menu bar, or press the F9 key, or click on the Update icon
    in the Tools toolbar to update the formula in the preview window or the document.
    in the Tools toolbar to update the formula in the preview window or the document. 
  3. 6)  In Math, save your changes to the formula after editing.
    In Writer, Calc, Impress, or Draw, click anywhere in your document away from the formula to leave editing mode, then save the document to save your changes to the formula. 

Formula layout

This section provides some advice on how to layout complex formulas in Math or in a LibreOffice document.

Using braces

LibreOffice Math knows nothing about order of operation within a formula. You must use braces (also known as curly brackets) to state the order of operations that occur within a formula. The following examples show how brackets can be used in a formula.

Example 1

2 over x + 1 gives the result 2 x + 1

Math has recognized that the 2 before and the x after the over as belonging to the fraction, and has represented them accordingly. If you want x+1 rather than x to be the denominator, you must bracket them together using braces so that both will be placed there.

Inserting braces into 2 over {x + 1} gives the result 2 x + 1 where x+1 is now the denominator.

Example 2

– 1 over 2 gives the result 1 2

Math has recognized the minus sign as a prefix for the 1 and has therefore placed it in the numerator of the fraction. If you wish to show that the whole fraction is negative, with the minus sign in front of the fraction, you must put the fraction in braces to signify to Math that the characters belong together.

Adding braces to into the markup language {1 over 2} gives the result 1 2 and the whole fraction is now negative.

Example 3

When braces are used in markup language, they are used to define the layout of the formula and are not displayed or printed. If you want to use braces within your formula, you use the commands lbrace and rbrace within the markup language.

x over {–x + 1} gives the result x x + 1
Replace the braces using the commands lbrace and rbrace in the markup language. Writing x over lbrace –x + 1 rbrace and the result is x { x + 1 }

Brackets and matrices

If you want to use a matrix in a formula, you have to use a matrix command. For example, matrix { a # b ## c # d } gives the resulting matrix a b c d in the formula, where rows are separated by two hashes (#) and entries within each row are separated by one hash (#).
Normally, when you use brackets within a matrix, the brackets do not scale as the matrix increases in size. For example, ( matrix { a # b ## c # d } ) gives the result ( a b c d )
To overcome this problem, LibreOffice Math provides scalable brackets that grow in size to match the size of a matrix. The commands left( and right) have to be used to create scalable brackets within a matrix. For example, left( matrix { a # b ## c # d } right) gives the result ( a b c d ) where the matrix is now bracketed by scalable brackets.

Scalable brackets can be used with any element of a formula, such as a fraction or square root.

Use the commands left[ and right] to obtain scalable square brackets. A list of all brackets available within Math can be found in Appendix A, Commands Reference, in the Math Guide.

If you want all brackets to be scalable, go to Format > Spacing to open the Spacing dialog. Click on Category, select Brackets from the drop-down list and then select the option Scale all brackets.

Unpaired brackets

When using brackets in a formula, Math expects that for every opening bracket there will be a closing one. If you forget to add a closing bracket, Math places an inverted question mark next to where the closing bracket should have been placed. This inverted question mark disappears when all the brackets are paired. However, an unpaired bracket is sometimes necessary and you have the following options.

Non-scalable brackets

A backslash \ is placed before a non-scalable bracket to indicate that the following character should not be regarded as a bracket, but as a literal character.

For example, the unpaired brackets in the formula [ a; b [ are deliberate, but gives the result a ; b . To remove the inverted question marks and create unpaired brackets, backslashes are added. The formula now becomes \ [ a; b \ [ and the result [ a ; b [ shows unpaired brackets without the inverted question marks.

Scalable brackets

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

Example

You want to create the formula | x | = { x for x 0 x for x < 0 and in the Formula Editor you enter
abs x = lbrace stack {x "for" x >= 0 # -x "for" x < 0.
However, this gives the incorrect result x for x 0 x for x < 0 | | x .

To remove the inverted question marks and create the correct formula, you have to use the markup commands left, right, and none.

To create the correct formula, change the entry in the Formula Editor to

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

Recognizing functions

In the basic installation of Math, Math outputs functions in normal characters and variables in italic characters. However, if Math fails to recognize a function, you can tell Math that you have just entered a function. Enter the markup command func before a function forces Math to recognize the following text as a function and uses normal characters.

For a full list of functions within Math, see the Math Guide.

Some Math functions have to be followed by a number or a variable. If these are 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, you have to enter a number, a variable, or a pair of empty brackets as a placeholder.

You can navigate through errors in a formula using the key F3 or the key combination Shift+F3.

Formulas over multiple lines

Suppose you want to create a formula that requires more than one line, for example x = 3 y = 1 .
Your first reaction would normally be to press the Enter key. However, if you press the Enter key, the markup language in the Formula Editor goes to a new line, but the resulting formula is written on one line. You must type the macro command newline each time you want to create and display a new line in a formula.

Example

x = 3
y = 1

gives the incorrect result x = 3 y = 1
x = 3 newline y = 1 gives the correct result x = 3 y = 1

It is not possible in Math to create multiple-line formulas when a line ends with an equals sign and you want to continue the calculation on a new line without completing the term on the right side of the equals sign. If you require a multiple line formula to have an equals sign at the end of a line without a term after the equals sign, then use either empty quotes "" or empty braces {} or the space characters grave ` or tilde ˜.

By default, a multiple line formula is centrally aligned. For more information on alignment using the equals sign, see the Math Guide.

Spacing between the elements in a formula is not set by using space characters in the markup language. If you want to add spaces into the 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 the Math Guide.

Adding limits to sum/integral commands

The sum and integral commands can take the parameters from and to if you want to set the lower and upper limits respectively. The parameters from and to can be used singly or together as shown by the following examples. For more information on the sum and integral commands, see the Math Guide.

Examples

sum from k = 1 to n a_k gives the result k = 1 n a k
int from 0 to x f(t) dt gives the result 0 x f ( t ) dt
int_0^x f(t) dt gives the result 0 x f ( t ) dt
int from Re f gives the result f
sum to infinity 2^{-n} gives the result 2 n

Writing derivatives

When writing derivatives, you have to tell 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 each side of the element to surround the element and make the derivative as shown by the following examples.

Examples

{df} over {dx} gives the result df dx
{partial f} over {partial y} gives the result f y
{partial^2 f} over {partial t^2} gives the result 2 f t 2

To write function names with primes, as is normal in school notation, you must first add the symbols to the catalog. See the Math Guide for more information.

Markup language characters as normal characters

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

The Special Characters dialog used by other LibreOffice modules is not available in Math. If you regularly require special characters in Math, the characters should be added to the catalog of Math symbols. See the Math Guide for more information.

Text in formulas

To include text in a formula, you have to enclose it in double-quotes, for example x " for " x >= 0 in markup language will create the formula x for x 0 . All characters, except double quotes, can be used in text. However, if you require double quotes in the formula text, then you have to create the text with double quotes in LibreOffice Writer, then copy and paste the text into the Formula Editor as shown in Figure 5.

The font used for text in a formula will be the default font that has been set in the Fonts dialog. For more information on how to change fonts used for in formulas, see “Changing formula appearance” on page 17.

By default, text alignment is left-justified in formulas. To change text alignment, see “Adjusting formula alignment” on page 20.

Formatting commands are not interpreted within text used in formulas. If you want to use formatting commands within formula text, then you must break up the text using double quotes in the Formula Editor.

 

Figure 5: Example of double quotes in formula text

 

Example

Enter the following in the Formula Editor:

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

creates the following text in a formula In isosceles triangles, the base angles are equal

Aligning formulas using equals sign

LibreOffice Math does not have a command for aligning formulas on a particular character. However, you can use a matrix to align formulas on a character and this character is normally the equals sign (=).

Example

Creating the matrix:

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

gives the following result, where formulas are aligned on the equals sign x + y = 2 x = 2 y

The empty braces each side of the equals sign are necessary because the equals sign is a binary operator and requires an expression on each side. You can use spaces, or ` or ~ characters each side of the equals sign, but braces are recommended as they are easier to see within the markup language.

You can reduce the spacing on each side of the equals sign if you change the inter-column spacing of the matrix. See “Adjusting formula spacing” on page 19 for information on how to adjust adjust formula spacing.

Changing formula appearance

Formula font size

Current formula font size

To change the font size used for a formula already inserted in Math or another LibreOffice module:

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

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

  3. 3)  Select a different font size using the Base size spinner or type a new font size in the Base Size box. 

  4. 4)  Click OK to save your changes and close the dialog. An example result when you change font size is shown below. 

Example

Default font size 12pt: π 3.14159
After font size change to 18pt: π 3.14159
 

Figure 6: Font Sizes dialog

 

Default formula font size

To change the default font size used for all formulas in Math or another LibreOffice module:

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

  2. 2)  Select a different font size using the Base size spinner or type a new font size in the Base Size box. 

  3. 3)  Click Default and confirm your changes to the base size font. Any formulas created from this point on will use the new base size font for formulas. 

  4. 4)  Click OK to save your changes and close the Font Sizes dialog. 

If you have already inserted formulas into a document and you change the default font size, only formulas inserted after the change in default font size will use the new default settings. You have to individually change the font size of formulas already inserted if you want these formulas to use the same font size as the default settings. For more information on changing the font size, see the Math Guide.

Formula fonts

Current formula fonts

To change the fonts used for the current formula in Math or another LibreOffice module:

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

  2. 2)  Go to Format > Fonts on the menu bar to open the Fonts dialog (Figure 7). 

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

  4. 4)  If the font you want to use does not appear in the drop-down list, click Modify and select the option from the context menu to open a fonts dialog. Select the font you want to use and click OK to add it to the drop-down list for that option. 

  5. 5)  Click OK to save your changes and close the Fonts dialog. 

 

Figure 7: Fonts dialog

 

Default formula fonts

To change the default fonts used for all formulas in Math or another LibreOffice module:

  1. 1)  Before inserting any formulas into a document, go to Format > Fonts on the menu bar to open the Fonts dialog (Figure 7). 

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

  3. 3)  If the font you want to use does not appear in the drop-down list, click Modify and select the option from the context menu to open a fonts dialog. Select the font you want to use and click OK to add it to the drop-down list for that option. 

  4. 4)  Click Default and confirm your changes to the fonts. Any formulas created from this point on will use the new fonts for formulas. 

  5. 5)  Click OK to save your changes and close the Fonts dialog. 

If you have already inserted formulas into a document and you change the default fonts, only formulas inserted after the change in default fonts will use the new default settings. You have to individually change the font of formulas already inserted if you want these formulas to use the same font as the default settings. For more information on changing the font, see the Math Guide.

Adjusting formula spacing

Use the Spacing dialog (Figure 8) to determine the spacing between formula elements. The spacing is specified as a percentage in relation to the defined base size for fonts.

Current formula spacing

To change the spacing used for the current formula in Math or another LibreOffice module:

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

  2. 2)  Go to Format > Spacing on the menu bar to open the Spacing dialog (Figure 8). 

  3. 3)  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. 

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

  5. 5)  Check the result in your formula. If it is not to your satisfaction, repeat the above steps. 

 

Figure 8: Spacing dialog

 

Default formula spacing

To change the default spacing used for all formulas in Math or another LibreOffice module:

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

  2. 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. 3)  Click Default and confirm your changes to the formula spacing. Any formulas created from this point on will use the new spacing for formulas. 

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

If you have already inserted formulas into a document and you change the spacing, only formulas inserted after the change in spacing will use the new default settings. You have to individually change the spacing of formulas already inserted if you want these formulas to use the same spacing as the default settings. For more information on changing the formula spacing, see the Math Guide.

Adjusting formula alignment

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

It is not possible to align formulas on a particular character and formula alignment (using the method described below) does not apply to text elements, which are always aligned left.

Independent of using formula alignment given below, it is possible to align formulas using the commands alignl, alignc and alignr. These commands also work for text elements.

Current formula alignment

To change the alignment used for the current formula in Math or another LibreOffice module:

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

  2. 2)  Go to Format > Alignment on the menu bar to open the Alignment dialog (Figure 9). 

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

  4. 4)  Click OK and check the result in your formula. If it is not to your satisfaction, repeat the above steps. 

 

Figure 9: Alignment dialog

 

Default formula alignment

To change the default alignment used for all formulas in Math or another LibreOffice module:

  1. 1)  Before inserting any formulas into a document, go to Format > Alignment on the menu bar to open the Alignment dialog (Figure 9). 

  2. 2)  Select either Left, Centered, or Right for horizontal alignment. 

  3. 3)  Click Default and confirm your changes to the formula alignment. Any formulas created from this point on will use the new alignment for formulas. 

  4. 4)  Click OK and check the result in your formula. If it is not to your satisfaction, repeat the above steps. 

If you have already inserted formulas into your document and you change the formula alignment, only formulas inserted after the change in alignment will use the new default settings. You have to individually change the alignment of formulas already inserted if you want these formulas to use the same alignment as the default settings.

Changing formula color

Character color

To change the color of the characters used in a formula, use the command color in the markup language. This command only works on the formula element immediately after the color name. For example, entering the markup language color red ABC 5 times 4 gives the result   ABC 5 × 4 .
To change the color of the whole formula, you have to enclose the whole formula within brackets. For example, entering the markup language color red {ABC 5 times 4} gives the result ABC 5 × 4 .

For information on the colors available in Math, see the Math Guide.

For ease of use, the Elements window includes the category Attributes, which lists standard colors. Click on the required color to insert the command into your formula.

Background color

It is not possible to select a background color for formulas in LibreOffice Math. The background color for a formula is by default the same color as the document or frame that the formula has been inserted into. However, in LibreOffice documents, you can use object properties to change the background color for a formula. For more information on using a background color (area fill for objects) with a formula, please refer to the user guides for Writer, Calc, Draw, and Impress.

Formula library

If you regularly insert the same formulas into your documents, you can create a formula library using formulas that you have created using the Formula Editor. Individual formulas can be saved as separate files using the ODF format for formulas with the file suffix of .odf, or in MathML format with the file suffix of .mml.

You can use LibreOffice Math, Writer, Calc, Draw, or Impress to create formulas and build up your formula library.

Using Math

  1. 1)  Create a folder on your computer to contain your formulas. Give the folder a memorable name, for example Formula Library. 

  2. 2)  In LibreOffice, go to File > New > Formula on the menu bar, or click on Math Formula in the opening splash screen to open LibreOffice Math and create your formula using the Formula Editor. See “Formulas as separate documents or files” on page 5 for more information. 

  3. 3)  Go to File > Save As on the menu bar or use the keyboard shortcut Ctrl+Shift+S to open a Save As dialog. 

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

  5. 5)  Type a memorable name for your formula in the File name text box. 

  6. 6)  Select from the drop-down list for File type either ODF Formula (.odf) or MathML 1.01 (.mml) as the file type for your formula. 

  7. 7)  Click Save to save the formula and close the Save As dialog. 

Using Writer, Calc, Draw, or Impress

  1. 1)  Create a folder on your computer to contain your formulas. Give the folder a memorable name, for example Formula Library. 

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

  3. 3)  Go to Insert > Object > Formula on the menu bar to open the Formula Editor and create your formula. See “Formulas in LibreOffice documents” on page 6 for more information. 

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

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

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

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

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

Using your formula library

You cannot insert a formula from your library into a document by dragging and dropping using the mouse, nor by using Insert > File on the menu bar. You must insert a formula from your library into your document as an OLE object.

  1. 1)  Open the document in Writer, Calc, Draw, or Impress. 

  2. 2)  Go to Insert > Object > OLE Object on the menu bar to open the Insert OLE Object dialog. 

  3. 3)  Select the option Create from file

  4. 4)  Click Search to open a file browser dialog. 

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

  6. 6)  Select the formula you want to insert and click Open, or double-click on the formula you want to insert. 

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

Formulas in Writer

When a formula is inserted into a document, LibreOffice Writer inserts the formula into a frame and treats the formula as an OLE object. Double-clicking on an inserted formula will open the Formula Editor in LibreOffice Math, where you can edit the formula.

This section explains what options you can change for each individual formula within a Writer document. Please refer to the chapters on styles in the Writer Guide for information on how to change the default settings for frame styles for OLE objects.

Automatic formula numbering

Automatic numbering of formulas for cross-reference purposes can only be carried out in LibreOffice Writer.

Numbering

  1. 1)  Start a new line in your document. 

  2. 2)  Type fn (mnemonic for formula numbered) and then press the F3 key. A two-column table with no borders is inserted into the document with the left column containing a sample formula and the right column containing a reference number, as shown below. 

ABC 5 × 4
 

(1)

  1. 3)  Delete the sample formula and insert your formula as an object in the left column. See “Creating formulas” on page 7 for more information on inserting formulas. 

Alternatively, you can first insert your formula into the document, then carry out Steps 1 and 2 above, replacing the sample formula with your formula.

If you want to use square parentheses instead of round ones around the formula number, or if you want the formula number to be separated from the formula by tabs instead of using a table, then you need to modify the AutoText entry for fn. Refer to the section on AutoText in Chapter 4, Getting Started with Writer.

Cross-referencing

  1. 1)  Click in the document where you want the cross-reference to appear. 

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

  3. 3)  Click on the Cross-references tab, then select Text in the Type section. 

  4. 4)  In the Selection section, select the formula number you want to refer to. 

  5. 5)  In the Insert reference to section, select Reference and click Insert

  6. 6)  When you have finished creating cross-references, click Close to close the Fields dialog. 

To insert the cross-reference number without parentheses, select Numbering instead of Reference in the Insert reference to section.

 

Figure 10: Fields dialog – Cross-references page

 

Anchoring formulas

A formula is treated as an object within Writer and its default anchoring is As character within a paragraph when it is inserted into a document. To change the anchoring of a formula object:

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

  2. 2)  Select a new anchoring option from the context sub-menu. The anchoring positions available are To page, To paragraph, To character, or As character

Alternatively,

  1. 1)  Right-click on the selected formula object and select Object from the context menu, or go to Format > Frame/Object on the menu bar to open the Object dialog (Figure 11). 

  2. 2)  Make sure the Type page is selected and select a new anchoring position from the Anchor section. 

  3. 3)  Click OK to save your changes and close the Object dialog. 

 

Figure 11: Object dialog – Type page with Anchor options

 

The anchoring options are not available in the Object dialog when you are making changes to the various options available for frame styles. For more information on how to modify frame styles, please refer to the chapters on styles in the Writer Guide.

Vertical alignment

The normal default setting for vertical alignment for formula objects is to use the text base line as a reference. This default setting can be changed by modifying the formula frame style. See the chapters on styles in the Writer Guide for more information.

To change the vertical alignment position of an individual formula object:

  1. 1)  Right-click on the selected formula object and select Object from the context menu, or go to Format > Frame/Object to open the Object dialog (Figure 11). 

  2. 2)  Make sure the Type page is selected and select a new alignment position from the drop-down list in the Position section. The vertical alignment options available are Top, Bottom, Center or From bottom

  3. 3)  If necessary, type in the text box a plus or minus value for vertical alignment. This option is only available if From bottom vertical alignment has been selected. 

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

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

 

Figure 12: Object dialog – Wrap page

 

If the Position section in the Object dialog is grayed out and not available, then go to Tools > Options > LibreOffice Writer > Formatting Aids and uncheck the option Math baseline alignment. This setting is stored with the document and applies to all formulas within it. Any new documents created will also use this setting for Math baseline alignment.

Object spacing

A formula object, when inserted into a Writer document, has spacing on each side. The default value used for spacing is set within the frame style for formula objects and can be changed by modifying the formula frame style, see the chapters on styles in the Writer Guide for more information.

You can individually adjust the spacing for each formula object within a document as follows:

  1. 1)  Create the formula in your Writer document. 

  2. 2)  Right-click on the selected formula object and select Object from the context menu, or go to Format > Frame/Object on the menu bar to open the Object dialog. 

  3. 3)  Click on the Wrap tab to open the Wrap page in the Object dialog (Figure 12). 

  4. 4)  In the Spacing section, enter the spacing value for Left, Right, Top and Bottom spacing. 

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

Text mode

In large formulas placed within a line of text, the formula elements can often be higher than the text height. Therefore, to make large formulas easier to read, it is recommended to always insert them into a separate paragraph of their own.

However, 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 will try to shrink the formula to fit the text height. The numerators and denominators of fractions are shrunk, and the limits of integrals and sums are placed beside the integral/sum sign, as shown in the following example.

Example

A formula in a separate paragraph:

i = 2 5 i 2
 
and the same formula embedded into a line of text using text mode format: i = 2 5 i 2

Background and borders

The default setting for background (area fill) and borders for formula objects is set by the formula frame style. To change this default setting for formula frame style, refer to the chapters on styles in the Writer Guide. However, for individual formulas in a document, you can change the background 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 object depends on the setting of the formula font size; see the Math Guide for more information.

Backgrounds

  1. 1)  In the document, select the formula where you wish to change the background. 

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

  3. 3)  Click on the Area tab and select the type of fill you want to use for the formula from the Fill drop-down list (Figure 13). 

  4. 4)  Select the options you want to use for the formula background. The options change depending on the type of fill selected. 

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

 

Figure 13: Object dialog – Area page

 

Borders

  1. 1)  In the document, select the formula where you want to change the borders. 

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

  3. 3)  Click on the Borders tab and select the options you want to use for the formula borders (Figure 14). 

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

 

Figure 14: Object dialog – Borders page

 

Quick insertion of formulas

To quickly insert a formula into a Writer document without opening the Formula Editor, where you know the markup language for the formula:

  1. 1)  Enter the formula markup language into the document at the position where you want the formula. 

  2. 2)  Select the markup language. 

  3. 3)  Go to Insert > Object on the menu bar and select Formula, or click on the Formula icon on the Standard toolbar to create a formula from the selected markup language. 

If the Formula icon is not displayed on the Standard toolbar, then right-click in an empty area on the toolbar, select Visible Buttons from the context menu, then select Formula from the available options.

Formulas in Calc, Draw, and Impress

In Calc, Draw, and Impress, formulas are inserted as OLE objects without any background (area fill) or borders. See the Math Guide for more information.

Each formula object is inserted into a spreadsheet, drawing, or slide as follows:

Anchoring formulas

Calc

A formula object can be anchored into a spreadsheet as To Page (default setting), or as To Cell. To change the anchoring type of formulas in a Calc spreadsheet:

  1. 1)  Select the formula object in the spreadsheet. 

  2. 2)  Right-click on the formula and select Anchor > To Page or To Cell from the context menu 

  3. 3)  Alternatively, go to Format > Anchor on the menu bar and select To Page or To Cell

Draw and Impress

When a formula is inserted into a drawing or slide, it is inserted as a floating OLE object and is not anchored to any particular position in a drawing or slide.

Formula object properties

Formula objects in Calc, Draw, and Impress can be modified just like any other object that has been placed in a spreadsheet, drawing, or presentation, with the exception of formula object size and changing the format of any text within a formula. For more information on how to change object properties, see the Calc Guide, Draw Guide, and Impress Guide. For more information on formula object size and formatting formula text, see the Math Guide.

The following points will help you select which dialog to use if you want to change the properties of formula objects.

Formulas in charts

A chart in a Calc spreadsheet is itself an OLE object; therefore you cannot use the Formula Editor to create and insert a formula into a chart.

To insert a formula into a chart, create the formula first using the Formula Editor and copy the formula to the clipboard. You then create the chart in Calc and paste the formula into the chart. The formula is automatically converted into the correct format for insertion into a chart.

If you want to change the formula at a later date, then you must repeat the whole process of creating, copying, and pasting.

Impressum (Legal Info) | Privacy Policy | Statutes (non-binding English translation) - Satzung (binding German version) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License v2.0. “LibreOffice” and “The Document Foundation” are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy. LibreOffice was based on OpenOffice.org.