Formula Layout

From Apache OpenOffice Wiki
Jump to: navigation, search



Formula Layout

The most difficult part of using Math comes when writing complicated formulas. This section provides some advice.

Brackets Are Your Friends

Math knows nothing about order of operation. You must use brackets to state the order of operations explicitly. Consider the following example.

Markup Result
2 over x + 1
2 over {x + 1}

Equations Over More Than One Line

Suppose you want to type an equation covering more than one line. For example:

Your first reaction would be to simply press the  ↵ Enter  key. However, if you press the  ↵ Enter  key, though the markup goes to a new line, the resulting equation does not. You must type the newline command explicitly. This is illustrated in the table below.

Markup Result
x = 3

y = 1

x = 3 newline

y = 1

How do I Add Limits to My Sum/Integral?

The sum and int commands can (optionally) take the parameters from and to. These are used for lower and upper limits respectively. These parameters can be used singly or together. Limits for integrals are usually treated as subscripts and superscripts. Remember that subscripts are indicated with _ and superscripts are indicated with ^.

Markup Result
sum from k = 1 to n a_k
int from 0 to x f(t) dt

or int_0^x f(t) dt

AOO41GS09 017.png
int from Re f
sum to infinity 2^{-n}
Documentation note.png For more details on integrals and sums, see the Math Guide.

Brackets with Matrices Look Ugly!

For background, we start with an overview of the matrix command.


Markup Result
matrix { a # b ## c # d }
Documentation note.png Rows are separated by two #'s and entries within each row are separated by one #.

The first problem people have with matrices is that brackets do not scale with the matrix.

Markup Result
( matrix { a # b ## c # d } )

Math provides scalable brackets. That is, the brackets grow in size to match the size of their contents. Use the commands left (and right) to make scalable brackets.

Markup Result
left( matrix { a # b ## c # d } right)
Tip.png Use left[ and right] to obtain square brackets.


How do I Make a Derivative?

Making derivatives essentially comes down to one trick: Tell Math it's a fraction.

In other words, you have to use the over command. Combine this with either the letter d (for a total derivative) or the partial command (for a partial derivative) to achieve the effect of a derivative.

Documentation note.png Notice that we have to use braces (squiggly brackets) to make the derivative.
Markup Result
{df} over {dx}
{partial f} over {partial y}
{partial^2 f} over {partial t^2}

How do I Align My Equations at the Equals Sign?

Math does not have a command for aligning equations on a particular character, but you can use a matrix to do this, as shown below.

Markup Result
matrix{

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

AOO41GS09 018.png

The empty braces around = are necessary because = is a binary operator and thus needs an expression on each side.

You can reduce the spacing around = if you change the inter-column spacing of the matrix:

  1. With the equation editor open, choose Format → Spacing from the menu bar.
  2. In the Spacing dialog (Figure 217), click the Category button and select Matrices in the drop-down menu.
  3. Enter 0% for Column spacing and click  OK .
AOO41GS09 016.png
Figure 217: Changing spacing in a matrix formula
Content on this page is licensed under the Creative Common Attribution 3.0 license (CC-BY).
Personal tools