# LibreOffice 3.4入门/Math入门

## 數學是什麼？

 注意 方程式編輯器用於繕打含符號的方程式，而非用於計算或是數值求解。若您想要進行計算或是數值求解，請參閱Calc入門。
${\displaystyle {\frac {{\mathit {df}}\left(x\right)}{\mathit {dx}}}=\ln \left(x\right)+{\tan }^{-1}\left({x}^{2}\right)}$
(1)

## Entering a formula

The equation editor uses a markup language to represent formulas. For example, %beta creates the Greek character beta (${\displaystyle \beta }$). This markup is designed to read in a similar way to English whenever possible. For example, a over b produces a fraction: ${\displaystyle {\frac {a}{b}}}$.

You can enter a formula in three ways:

• Select a symbol from the Elements window.
• Right-click on the equation editor and select the symbol from the context menu.
• Type markup in the equation editor.

The context menu and the Elements window insert the markup corresponding to a symbol. This provides a convenient way to learn the LibreOffice Math markup.

 Note Click on the document body to exit the formula editor. Double-click on a formula to enter the formula editor again.

### The Elements window

The simplest method for entering a formula is the Elements window.

[[Image:|thumb|Figure 247: Symbols are divided into categories]]

The Elements window is divided into two main parts.

• The top shows the symbol categories. Click on these to change the list of symbols.
• The bottom shows the symbols available in the current category.

 Tip You can hide or show the Elements window with View > Elements.

#### Example 1:${\displaystyle 5\times 4}$

For this example we will enter a simple formula:${\displaystyle 5\times 4}$. On the Elements window:

1. Select the top-left button of the categories (top) section.
2. Click on the multiplication symbol.
[[Image:|thumb|Figure 248: Selecting the multiplication symbol]]

When you select the multiplication symbol on the Elements window, two things happen:

• The equation editor shows the markup:${\displaystyle {\text{? times ?}}}$
• The body of the document shows a gray box like this:$\displaystyle ❑\times ❑$
[[Image:|thumb|Figure 249: Result of selecting the multiplication symbol]]

The <?> symbols shown in Figure 249 are placeholders that you can replace by other text, for example 5 and 4. The equation will update automatically, and the result should resemble Figure 250.

 Tip To keep the equation from updating automatically, select View >AutoUpdate display. To update a formula manually, press F9 or select View > Update.
[[Image:|thumb|Figure 250: Result of entering 5 and 4 next to the times operator]]

### Right-click (context) menu

Another way to access mathematical symbols is to right-click on the equation editor. This pops up the menu shown in Figure 251. The items in this menu correspond exactly to those in the Elements window.

[[Image:|thumb|Figure 251: Right-click (context) menu]]

### Markup

You can type the markup directly in the equation editor. For example, you can type 5 times 4 to obtain ${\displaystyle 5\times 4}$. If you know the markup, this can be the fastest way to enter a formula.

 Tip The formula markup resembles the way the formula reads in English.

Below is a short list of common equations and their corresponding markup.

Display Command Display Command
${\displaystyle a=b}$ a = b ${\displaystyle {\sqrt {a}}}$ sqrt {a}
${\displaystyle {a}^{2}}$ a^2 ${\displaystyle {a}_{n}}$ a_n
${\displaystyle \int f\left(x\right){\mathit {dx}}}$ int f(x) dx ${\displaystyle \sum {a}_{n}}$ sum a_n
${\displaystyle a\leq b}$ a <= b ${\displaystyle \infty }$ infinity
${\displaystyle a\times b}$ a times b ${\displaystyle x\cdot y}$ x cdot y

### Greek characters

Greek characters (${\displaystyle \alpha ,\beta ,\gamma ,\theta }$, etc) are common in mathematical formulas. These characters are not available in the Elements window or the right-click menu. Fortunately, the markup for Greek characters is simple: Type a % sign followed by the name of the character, in English.

• To write a lowercase character, type the name of the character in lowercase.
• To write an uppercase character, type the name of the character in uppercase.

A complete table of Greek characters is provided in the Math Guide. See the table below for some examples.

Lowercase Uppercase
%alpha${\displaystyle \rightarrow \alpha }$ %ALPHA${\displaystyle \rightarrow \mathrm {A} }$
%beta ${\displaystyle \rightarrow \beta }$ %BETA ${\displaystyle \rightarrow \mathrm {B} }$
%gamma${\displaystyle \rightarrow \gamma }$ %GAMMA${\displaystyle \rightarrow \Gamma }$
%psi ${\displaystyle \rightarrow \psi }$ %PSI ${\displaystyle \rightarrow \Psi }$
%phi ${\displaystyle \rightarrow \phi }$ %PHI ${\displaystyle \rightarrow \Phi }$
%theta${\displaystyle \rightarrow \theta }$ %THETA${\displaystyle \rightarrow \Theta }$

Another way to enter Greek characters is by using the Symbols catalog window. Choose Tools > Catalog. This window is shown in Figure 252. Under Symbol set, select Greek and double-click on a Greek letter from the list. The markup name of the character is shown below the list window.

[[Image:|thumb|Figure 252: Symbols catalog, used for entering Greek characters and some special symbols]]

#### Example 2:${\displaystyle \pi \simeq 3.14159}$

For this example we will suppose that:

• We want to enter the above formula (the value of pi rounded to 5 decimal places).
• We know the name of the Greek character (pi).
• But we do not know the markup associated with the ${\displaystyle \simeq }$ symbol.

Step 1: Type % followed by the text pi. This displays the Greek character ${\displaystyle \pi }$.

Step 2: Open the Elements window (View > Elements).

Step 3: The ${\displaystyle \simeq }$ symbol is a relation, so we click on the Relations button. If you hover the mouse over this button you see the tooltip Relations (Figure 253).

Figure 254 shows the Selection window after clicking the Relations button. The symbol we want is circled.

 [[Image:]] Figure 253: Tooltip indicates the Relations button [[Image:]] Figure 254: After selecting Relations

Step 4: Click on the a${\displaystyle \simeq }$b symbol. The equation editor now shows the markup %pi<?> simeq <?>.

Step 5: Delete the <?> text and add 3.14159 at the end of the equation. We end up with the markup %pi simeq 3.14159. The result is shown in Figure 255.

[[Image:|thumb|Figure 255. Final result]]

## Customizations

### Formula editor as a floating window

The formula editor can cover a large part of the Writer window. To turn the formula editor into a floating window, do this:

1. Hover the mouse over the editor frame, as shown in Figure 256.
2. Hold down the Control key and double-click.
[[Image:|thumb|Figure 256: Turning the formula editor into a floating window]]

Figure 257 shows the result. You can dock the floating window again by using the same steps. Hold down the Control key and double-click the window frame.

[[Image:|thumb|Figure 257: Formula editor as a floating window]]

### How can I make a formula bigger?

This is one of the most common questions people ask about LibreOffice Math. The answer is simple, but not intuitive:

1. Start the formula editor and choose Format > Font size.
[[Image:|thumb|Figure 258: Changing the font size for a formula]]
1. Select a larger font size under Base size (top-most entry).
[[Image:|thumb|Figure 259. Edit Base size (top) to make a formula bigger]]

The result of this change is illustrated in Figure 260.

[[Image:|thumb|Figure 260. Result of changing the base font size]]

## Formula layout

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

### Brackets are your friends

LibreOffice 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 ${\displaystyle {\frac {2}{x}}+1}$
2 over {x + 1} ${\displaystyle {\frac {2}{x+1}}}$

### Equations over more than one line

Suppose you want to type an equation covering more than one line. For example:${\displaystyle {\begin{array}{c}x=3\\y=1\end{array}}}$

Your first reaction would be to simply press the Enter key. However, if you do this, the markup goes to a new line but 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

${\displaystyle x=3y=1}$
x = 3 newline

y = 1

${\displaystyle {\begin{array}{c}x=3\\y=1\end{array}}}$

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

Markup Result
sum from k = 1 to n a_k ${\displaystyle \sum _{k=1}^{n}{a}_{k}}$
int from 0 to x f(t) dt

or

int_0^x f(t) dt

${\displaystyle {\underset {0}{\overset {x}{\int }}}f\left(t\right){\mathit {dt}}}$ or ${\displaystyle {\int }_{0}^{x}f\left(t\right){\mathit {dt}}}$
int from Re f ${\displaystyle {\underset {\Re }{\int }}f}$
sum to infinity 2^{-n} ${\displaystyle \sum ^{\infty }{2}^{-n}}$
 Note For more details on integrals and sums, see the LibreOffice 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 } ${\displaystyle {\begin{array}{cc}a&b\\c&d\end{array}}}$
 Note 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 } ) ${\displaystyle \left({\begin{array}{cc}a&b\\c&d\end{array}}\right)}$

LibreOffice Math also provides scalable brackets that 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) ${\displaystyle \left({\begin{array}{cc}a&b\\c&d\end{array}}\right)}$
 Tip Use left[ and right] to obtain scalable square brackets.

### How do I make a derivative?

Making derivatives essentially comes down to one trick: Tell LibreOffice 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.

 Note Notice that we have to use braces (squiggly brackets) to make the derivative.
Markup Result
{df} over {dx} ${\displaystyle {\frac {\mathit {df}}{\mathit {dx}}}}$
{partial f} over {partial y} ${\displaystyle {\frac {\partial f}{\partial y}}}$
{partial^2 f} over {partial t^2} ${\displaystyle {\frac {{\partial }^{2}f}{\partial {t}^{2}}}}$

### How do I align my equations at the equals sign?

LibreOffice 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
}

${\displaystyle {\begin{array}{rcl}x+y&=&2\\x&=&2-y\end{array}}}$

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

You can reduce the spacing around the = sign by changing the intercolumn spacing of the matrix:

1. With the equation editor open, choose Format > Spacing from the menu bar.
2. In the Spacing dialog (Figure 261), click the Category button and select Matrices in the drop-down menu.
3. Enter 0% for Column spacing and click OK.
[[Image:|thumb|Figure 261: Changing spacing in a matrix formula]]

## Numbering equations

Equation numbering is one of LibreOffice Math’s best hidden features. The steps are simple, but obscure:

1. Start a new line.
2. Type fn and then press F3.

The fn is replaced by a numbered formula:

${\displaystyle E={\mathit {mc}}^{2}}$
(2)

Now you can double-click on the formula to edit it. For example, here is the Riemann Zeta function:

${\displaystyle \zeta \left(z\right)=\sum _{n=1}^{\infty }{\frac {1}{{n}^{z}}}}$
(3)

You can cross-reference an equation (“as shown in Equation (2)”) with these steps:

1. Choose Insert > Cross-reference from the menu bar.
2. On the Cross-references tab (Figure 262), under Type, select Text.
3. Under Selection, select the equation number.
4. Under Format, select Reference.
5. Click Insert.

[[Image:|thumb|Figure 262. Inserting a cross-reference to an equation number ]]

Done! If you later add more equations to the paper before the referenced equation, all the equations will automatically renumber and the cross-references will update.

 Tip To insert the equation number without parentheses around it, choose Numbering under Format instead of Reference.

## Math commands reference

For a full list of the commands available in Math, please see the LibreOffice Math Guide.

• Unary / binary operators
• Relational operators
• Set operations
• Functions
• Operators
• Attributes
• Miscellaneous
• Brackets
• Formats
• Characters – Greek
• Characters – Special