Help:Editing Math Equations using TeX

From UBC Wiki
MathHelp.png This article is part of the MathHelp Tutoring Wiki
PhysicsHelp.png This article is part of the PhysicsHelp Tutoring Wiki


This is how you edit math equations using the TeX syntax to make nice looking equations. Please use TeX when writing math. Trying to put equations directly into the text doesn't look very nice and TeX is very easy to learn.

If you already use TeX, then all you need to know is that your normal syntax must be surrounded by tags:

  • For HTML rendering if possible
<math> syntax </math>
  • For forced TeX rendering ( which produces an image )
<math> syntax ~</math>
<math> \displaystyle syntax </math>
<math> syntax \,\!</math>
<math> syntax \,</math>


The above forced rendering are explained in Forced PNG rendering

If you've never used TeX before, here's a crash course:

Fractions

To make a fraction use:

\frac{foo}{bar}

These render as:

Superscript and Subscript

To make superscripts and subscripts, use:

x^2
y_0

These render as:

Greek Letters

To make greek letters, you just need to know their names. Use a capital for the capital letter, a lower-case for the lower-case letter:

\pi
\theta
\omega
\Omega
\gamma
\Gamma
\alpha
\beta

These render as like:

Trig Stuff

You can use the following to render trig functions without italics so it looks nicer:

\cos(\theta)
\sin(\theta)
\tan(\theta)

These render as: , as opposed to:

cos(\theta)
sin(\theta)
tan(\theta)

Which look like:

In general, if you want to make words not in italics in math, use

\text{foo bar}

Which looks like instead of

Big Brackets

Usually, a normal parenthesis or bracket will do fine:

x^2 (2x + y)

Renders as:

But if you have big stuff like fractions, it doesn't always look as nice:

(\frac{\pi}{2})

renders as:

Instead, use:

x^2 \left(2x + y\right)
\left( \frac{\pi}{2} \right)

Which looks like:

Notice that these kinds of brackets are always the right size. They also work with square brackets:

\left[ \frac{\pi}{2} \right]
\left[ x^2 (2x + y) \right]

Renders as:

Other

These are some other things that may be useful. In general, if you want to know how to make a type of symbol, you can find many usefuly lists by searching for TeX or LaTeX math symbols.

\sqrt{foo}

\int_a^b f(x)dx

\pm

\mp

\approx

One thing you may notice is that adding spaces between symbols will not add more space in the rendered output.

a_0         a_1
a_0 a_1

These will both render as:

If you want to force spacing between symbols, you have to use the "~" symbol:

a_0~~~~~~~~~a_1

renders as:

Also, it can be useful to note that there as two kinds of math font that the wiki will try to use. One is a smaller font which fits better into a line of normal text, and the other is a larger font which looks nicer when you have an equation on its own line. Whenever you make somthing "big" like a fraction or square root symbol, the wiki will automatically use bigger font. Sometimes you may want to force a line to be bigger because it looks nicer. I have found no nice way to do this other than it just so happens that if you put a "~" at the end of a line that line will be rendered in the bigger font; since the "~" is at the end you won't notice that there is technically an extra blank space there.

A\cos(\omega t)</math>
A\cos(\omega t)~</math>

These will render as:

Lastly, don't be afraid to nest things together to make really complicated looking expressions:

v_2 = \sqrt{\frac{2\left(P_1 - P_2\right)}{\rho \left(1 - {\left(\frac{A_2}{A_1}\right)}^2\right)}}

will render as: