There are two kinds of ways to display math on a page. You can either have inline math, which is part of the line that you type it in, like \(x^2 + {A \over B}\). Or you can have display math, which is centered and enlarged: \[ x^2 + {A \over B} \]
In LyX, you can insert an inline equation with the keyboard shortcut control m or command m, depending on your operating system. You can also insert an equation by selecting insert, then math in the menu or by clicking on the equation button at the top of the page:
For a display equation, the keyboard shortcuts are instead control shift m or command shift m. You can also switch an equation's mode by selecting that equation and then pressing this button at the bottom of the page:In Microsoft Office, you can create an equation by clicking insert, then equation. You can also use the keyboard shortcut control = or alt =, depending on your version of Office.
You can then use a drop-down menu to switch an equation between inline and display mode.
If you are typing in a pure LaTeX environment (like in Overleaf), you can use \( x^2 \)
or $ x^2 $
to insert an inline equation like this: \( x^2 \). And you can use \[ x^2 \]
or $$ x^2 $$
to insert a display-mode equation like this: \[ x^2 \]
Below are a few examples for how to type math expressions. These examples only scratch the surface of what LaTeX math formatting can do, and Overleaf has a helpful tutorial here.
The carat symbol ^ (shift 6) can be used to add a superscript, raising the next character up and making it smaller. Likewise, an underscore _ (shift -) can be used to add a subscript, lowering the next character.
In some software, if you want to include multiple characters in a superscript or subscript, you will need to use curly braces { }.
Input: | Result: |
---|---|
x^2 | \( x^2 \) |
Q_d | \( Q_d \) |
A^B_C | \( A^B_C \) |
x^23 | \( x^23 \) |
x^{23} | \( x^{23} \) |
a^2 + b^2 = c^2 | \( a^2 + b^2 = c^2 \) |
\( \) |
To type a greek letter, first type a backslash \ (near the enter key) and then type the name of the letter. If you want a capital greek letter, capitalize the first character in the name.
Input: | Result: |
---|---|
\gamma | \( \gamma \) |
\Gamma | \( \Gamma \) |
\alpha \beta \gamma | \( \alpha \beta \gamma \) |
\alpha^\beta_\gamma | \( \alpha^\beta_\gamma \) |
\( \) |
Typing other math symbols is very similar to typing greek letters. You just need to know the name of the symbol in LaTeX. I've included some of the most common symbols below. A more expansive list can be found can be found here. And if you know what a symbol looks like but don't know what it's called, here's is a neat tool that lets you draw a symbol, and then gives you the LaTeX name for it.
Note that unlike greek letters, the names of these symbols are usually abbreviated to make them easier to type. For example, "Greater than or EQual to" is abbreviated to simply "\geq"
Input: | Result: |
---|---|
\geq | \( \geq \) |
\leq | \( \leq \) |
\to | \( \to \) |
\partial | \( \partial \) |
\infty | \( \infty \) |
\times | \( \times \) |
\cdot | \( \cdot \) |
\sqrt{2} | \( \sqrt{2} \) |
\( \) |
Oftentimes in math, you will see a symbol which looks like a normal letter, but written in a strange font. For example, \(\mathbb{R}\) is used to represent the real numbers, and \(\mathcal{L}\) is used as a symbol for Lagrangian optimization. These special fonts are called "Math Blackboard Bold" and "Math Caligraphy", and are abbreviated as mathbb and mathcal, respectively.
Input: | Result: |
---|---|
\mathbb{R} | \( \mathbb{R} \) |
\mathbb{ABCD} | \( \mathbb{ABCD} \) |
\mathcal{L} | \( \mathcal{L} \) |
\mathcal{ABCD} | \( \mathcal{ABCD} \) |
\( \) |
There are a few different ways to type fractions, as you can see below:
Input: | Result: |
---|---|
A/B | \( A/B \) |
A \over B | \( A \over B \) |
\frac{A}{B} | \( \frac{A}{B} \) |
\( \) |
In complex equations, curly braces can be used to control what is inside the fraction and what is not.
Input: | Result: |
---|---|
A + B \over C | \( A + B \over C \) |
A + {B \over C} | \( A + {B \over C} \) |
A + {B \over C} \over D | \( A + {B \over C} \over D \) |
\frac{A+\frac{B}{C}}{D} | \( \frac{A+\frac{B}{C}}{D} \) |
\( \) |
Some symbols have special formatting rules in display mode. For example, when we talk about the limit of a function as \(x\) approaches infinity, we want to place the symbols \(x\to\infty\) directly underneath the \(\lim\) symbol.
The following table shows three of these special symbols in inline mode:
Input: | Result: |
---|---|
\lim_{x \to \infty} | \( \lim_{x\to\infty} \) |
\int_A^B | \( \int_A^B \) |
\sum_{i=0}^N | \( \sum_{i=0}^N \) |
\( \) |
And here are those same symbols in display mode:
Input: | Result: |
---|---|
\lim_{x \to \infty} | \( \displaystyle \lim_{x \to \infty} \) |
\int_A^B | \( \displaystyle \int_A^B \) |
\sum_{i=0}^N | \( \displaystyle \sum_{i=0}^N \) |
\( \) |