LibreOffice Math Formula Syntax Rules
LibreOffice Math uses a dedicated markup language to convert plain-text commands into formatted mathematical expressions. Writing formulas in LibreOffice Math relies on a specific set of syntax rules covering token separation, grouping, operators, brackets, and literal text formatting. Understanding these fundamental rules ensures formulas render accurately across LibreOffice applications such as Writer, Calc, and Impress.
Whitespace and Grouping
LibreOffice Math ignores regular spaces, tabs, and line breaks within the code pane when rendering the visual formula. Spaces are solely used to separate distinct tokens, commands, and variable names.
- Explicit Spacing: To add visible spacing between
elements in a formula, use the grave accent (
`) for a small space or a tilde (~) for a large space. - Grouping Braces: Curly brackets
{}define logical groups and enforce order of operations without appearing in the final rendered formula. For example,x^{a + b}renders \(a + b\) as a unified superscript, whereasx^a + bonly places \(a\) in the superscript.
Case Sensitivity and Identifiers
- Keywords: Built-in keywords, operators, and
commands are case-insensitive. For example,
SQRT(x),sqrt(x), andSqrt(x)produce the identical square root symbol. - Variables and Characters: Variables are rendered in
italics by default and preserve their casing. Entering
xandXwill display distinct lowercase and uppercase italicized symbols.
Basic Operators and Structures
Math provides straightforward keywords for common mathematical operations:
- Fractions: The
overoperator creates standard vertical fractions:{numerator} over {denominator}. - Subscripts and Superscripts: The underscore
_generates subscripts, while the caret^generates superscripts:a_i^2. - Roots: The
sqrtkeyword generates square roots (sqrt{x}), whilenroot n xcreates the \(n\)-th root of an expression. - Multiplication and Division: Use
cdotfor a multiplication dot,timesfor a multiplication cross, anddivfor a division symbol.
Brackets and Delimiters
Parentheses () and square brackets [] typed
directly into the code pane render static, fixed-size delimiters.
- Scalable Brackets: To make brackets automatically
scale to the height of the enclosed expression (such as fractions or
matrices), prepend them with
leftandright. For example:left( {a over b} right). - Mismatched or Open Brackets: Every
leftkeyword must have a correspondingrightkeyword. If a bracket is only needed on one side, use thenonekeyword on the opposite side:left[ {a over b} right none. - Literal Curly Brackets: Because
{}are reserved for grouping, literal visible curly braces must be written usinglbraceandrbrace, or escaped as\{and\}.
Special Characters and Greek Letters
Greek letters and special symbols require a percent sign
(%) prefix:
- Lowercase Greek:
%alpha,%beta,%pi,%theta. - Uppercase Greek:
%ALPHA,%BETA,%PI,%THETA. - Special Symbols:
%infinityfor \(\infty\),%tendtofor an arrow \(\to\), andpartialfor partial derivatives.
Literal Text, Alignment, and Line Breaks
- Text Strings: Any word not recognized as a command
is treated as a variable and italicized. To display standard upright
text, enclose the string in double quotes:
"Total" = x + y. - Line Breaks: Standard line breaks inside the editor
do not split the rendered formula. To force a new line within an
equation, use the
newlinecommand. - Alignment: By default, multi-line formulas are
center-aligned. Line alignment can be modified globally using
alignl(left alignment),alignc(center alignment), oralignr(right alignment) at the start of a line.