Chapter 9
Getting Started with Math
LibreOffice’s Formula (Equation) Editor
This document is Copyright © 2012–2016 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.
Jean Hollis Weber  Hazel Russman  Laurent BallandPoirier 
John A Smith  Martin Saffron  Peter Schofield 
Olivier Hallot 


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

Regina Henschel  Christian Kühl  Florian Reisinger 
Gisbert Friege (Dmaths)  Jochen Schiffers 

Published 22 June 2016. Based on LibreOffice 5.1.
Windows or Linux  Mac equivalent  Effect 
Tools > Options menu selection  LibreOffice > Preferences  Access setup options 
Rightclick  Control+click and/or rightclick depending on computer setup  Open a context menu 
Ctrl (Control)  ⌘ (Command)  Used with other keys 
F5  Shift+⌘+F5  Open the Navigator 
F11  ⌘+T  Open the Styles and Formatting window 
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):
•On the menu bar, go to File > New > Formula.
•From the Start Center, click Math Formula.
•In Math, use the keyboard shortcut Ctrl+N.
•Use command Import MathML from the clipboard.
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 8.
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={\mathrm{mc}}^{2}$$ 
•In Writer, click in the paragraph where you want to insert the formula.
•In Calc, click in the spreadsheet cell where you want to insert the formula.
•In Draw and Impress, the formula is inserted into the center of the drawing or slide.
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 submenu, 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 8.
Figure 2 shows an example Writer document with the formula box selected ready for a formula to be entered.
You can insert elements into a formula using one of the following methods:
•Select a category from the dropdown list, then a symbol using the Elements window.
•Rightclick in the Formula Editor and select a category, then a symbol from the context menu.
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.
The Formula Editor also provides a context menu to access categories and symbols when creating a formula. Rightclick 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 subcontext menu. An example is shown in Figure 3.
Table 2: Example commands using markup language
Display  Command  Display  Command 
$$a=b$$  a = b  $$\sqrt{a}$$  sqrt {a} 
$${a}^{2}$$  a^2  $${a}_{n}$$  a_n 
$$\int f(x)\mathit{dx}$$  int f(x) dx  $$\sum {a}_{n}$$  sum a_n 
$$a\le b$$  a <= b  $$\mathrm{\infty}$$  infinity 
$$a\times b$$  a times b  $$x\cdot y$$  x cdot y 
Greek characters can also be entered into a formula using the Symbols dialog.
1)Make sure the cursor is in the correct position in the Formula Editor.
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)Select Greek from the Symbol set dropdown list. For italic characters, select iGreek from the dropdown list.
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)Click Close when you have finished entering Greek characters into the formula.
2)Enter %pi in the Formula Editor to enter the Greek character for pi (π).
3)Select the category Relations and symbol Is Similar Or Equal using one of the following methods:
Scalable brackets can be used with any element of a formula, such as a fraction or square root.
abs x = left lbrace stack {x "for" x >= 0 # x "for" x < 0} right none.
For a full list of functions within Math, see the Math Guide.
You can navigate through errors in a formula using the key F3 or the key combination Shift+F3.
•Add the character to the Math Catalog, for example the double quote character.
Note
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.
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 18.
By default, text alignment is leftjustified in formulas. To change text alignment, see “Adjusting formula alignment” on page 21.
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.
Enter the following in the Formula Editor:
"In " color blue bold "isosceles" "triangles, the base angles are equal"
matrix{ alignr x+y # {}={} # alignl 2 ## alignr x # {}={} # alignl 2y }
You can reduce the spacing on each side of the equals sign if you change the intercolumn spacing of the matrix. See “Adjusting formula spacing” on page 20 for information on how to adjust adjust formula spacing.
To change the font size used for a formula already inserted in Math or another LibreOffice module:
2)Go to Format > Font size on the menu bar to open the Font Sizes dialog (Figure 6).
3)Select a different font size using the Base size spinner or type a new font size in the Base Size box.
4)Click OK to save your changes and close the dialog. An example result when you change font size is shown below.
Example
To change the default font size used for all formulas in Math or another LibreOffice module:
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)Select a different font size using the Base size spinner or type a new font size in the Base Size box.
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)Click OK to save your changes and close the Font Sizes dialog.
Note
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.
To change the fonts used for the current formula in Math or another LibreOffice module:
2)Go to Format > Fonts on the menu bar to open the Fonts dialog (Figure 7).
3)Select a new font for each the various options from the dropdown lists.
4)If the font you want to use does not appear in the dropdown 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 dropdown list for that option.
5)Click OK to save your changes and close the Fonts dialog.
To change the default fonts used for all formulas in Math or another LibreOffice module:
1)Before inserting any formulas into a document, go to Format > Fonts on the menu bar to open the Fonts dialog (Figure 7).
2)Select a new font where required for each of the various options from the dropdown lists.
3)If the font you want to use does not appear in the dropdown 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 dropdown list for that option.
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)Click OK to save your changes and close the Fonts dialog.
Note
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.
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.
To change the spacing used for the current formula in Math or another LibreOffice module:
2)Go to Format > Spacing on the menu bar to open the Spacing dialog (Figure 8).
3)Click Category and select one of the options from the dropdown list. The options in the Spacing dialog change according to the category selected.
4)Enter new values for the spacing category and click OK.
5)Check the result in your formula. If it is not to your satisfaction, repeat the above steps.
To change the default spacing used for all formulas in Math or another LibreOffice module:
1)Before inserting any formulas into a document, go to Format > Spacing on the menu bar to open the Spacing dialog (Figure 8).
2)Click Category and select one of the options from the dropdown list. The options in the Spacing dialog change according to the category selected.
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)Click OK to save your changes and close the Spacing dialog.
Note
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.
To change the alignment used for the current formula in Math or another LibreOffice module:
2)Go to Format > Alignment on the menu bar to open the Alignment dialog (Figure 9).
3)Select either Left, Centered, or Right for horizontal alignment.
4)Click OK and check the result in your formula. If it is not to your satisfaction, repeat the above steps.
To change the default alignment used for all formulas in Math or another LibreOffice module:
1)Before inserting any formulas into a document, go to Format > Alignment on the menu bar to open the Alignment dialog (Figure 9).
2)Select either Left, Centered, or Right for horizontal alignment.
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)Click OK and check the result in your formula. If it is not to your satisfaction, repeat the above steps.
Note
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.
For information on the colors available in Math, see the Math Guide.
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 6 for more information.
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)Navigate to the folder you have created for your formula library.
5)Type a memorable name for your formula in the File name text box.
6)Select from the dropdown list for File type either ODF Formula (.odf) or MathML 1.01 (.mml) as the file type for your formula.
7)Click Save to save the formula and close the Save As dialog.
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 7 for more information.
4)Rightclick on the formula object and select Save Copy as from 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 text box.
7)Select from the dropdown list for File type either ODF Formula (.odf) or MathML 1.01 (.mml) as the file type for your formula.
8)Click Save to save the formula and close the Save As dialog.
2)Go to Insert > Object > OLE Object on the menu bar to open the Insert OLE Object dialog.
5)Navigate to the folder you have created for your formula library.
7)Click OK to insert the formula as an OLE object in the document and close the OLE Object dialog.
$${\mathit{ABC}5\times 4}$$  (1) 
3)Delete the sample formula and insert your formula as an object in the left column. See “Creating formulas” on page 8 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.
Note
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.
1)Click in the document where you want the crossreference to appear.
2)Go to Insert > Crossreference on the menu bar to open the Fields dialog (Figure 10).
3)Click on the Crossreferences tab, then select Text in the Type section.
4)In the Selection section, select the formula number you want to refer to.
5)In the Insert reference to section, select Reference and click Insert.
6)When you have finished creating crossreferences, click Close to close the Fields dialog.
Tip
To insert the crossreference number without parentheses, select Numbering instead of Reference in the Insert reference to section.
1)Rightclick 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)Make sure the Type page is selected and select a new anchoring position from the Anchor section.
3)Click OK to save your changes and close the Object dialog.
To change the vertical alignment position of an individual formula object:
1)Rightclick 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)Make sure the Type page is selected and select a new alignment position from the dropdown list in the Position section. The vertical alignment options available are Top, Bottom, Center or From bottom.
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)Select the type of text alignment from the dropdown list in the Position section. The text alignment options available are Base line, Character and Row.
5)Click OK to save your changes and close the Object dialog.
You can individually adjust the spacing for each formula object within a document as follows:
3)Click on the Wrap tab to open the Wrap page in the Object dialog (Figure 12).
4)In the Spacing section, enter the spacing value for Left, Right, Top and Bottom spacing.
5)Click OK to save your changes and close the Object dialog.
A formula in a separate paragraph:
1)In the document, select the formula where you wish to change the background.
3)Click on the Area tab and select the type of fill you want to use for the formula from the Fill dropdown list (Figure 13).
4)Select the options you want to use for the formula background. The options change depending on the type of fill selected.
5)Click OK to save your changes and close the Object dialog.