LeMill
Edit, tips for use and more...

How to write equations in LeMill

by Jukka Purma, Hans PƵldoja, Tarmo Toikkanen — last modified 2008-06-18 16:01
group: LeMill development


\longrightarrow \heartsuit \longleftarrow

You can use complex equations, mathematical formulas and logical symbols in LeMill by using TeX-notation. TeX/LaTeX is a typesetting language for describing formulas in unambiguous way: it might look complicated, but once you understand basics, it is easy to expand to anything mathematical you want to write. TeX is the name of the original math component and LaTeX is the expanded document generation language around TeX. Nowadays all tools and editors are basically LaTeX editors, so from now on we call these things LaTeX formulas. (For more information check Wikipedia's articles: TeX / LaTeX)

You insert LaTeX formulas in two ways: either by putting them inside text or as centered equations.

You separate latex equations from other text with following conventions:

\( ... \)  for in-text equations and 
\begin{equation}
...
\end{equation} for larger, centered equations.

Let's have an example:

This is a paragraph and this is an equation inside it:  a=\frac{v}{t} . This is useful if you want, for example use greek characters or logic in sentences.  \alpha \rightarrow \beta or  A \cap B .

The previous paragraph's code is here:

This is a paragraph and this is an equation 
inside it: \( a=\frac{v}{t} \) .
This is useful if you want, for example
use greek characters or logic expressions in sentences.
\( \alpha \rightarrow \beta \)or \( A \cap B \).

Another example

This is a larger equation.


m = \frac{m_0}{\sqrt{1-\frac{v^2}{c^2}}}

That was generated from this:

This is a larger equation.

\begin{equation}
m = \frac{m_0}{\sqrt{1-\frac{v^2}{c^2}}}
\end{equation}

How can I make sense of those commands?

First thing is to get a cheat sheet: http://amath.colorado.edu/documentation/LaTeX/Symbols.pdf The simplest commands are basic letters, numbers and the most common operators. These you just write inside the equation parenthesis:  0, 500, x, y, x*y=z
\( 0, 500, x, y, x*y=z \)
The next step is actual commands. From cheat sheet you'll notice that the commands always start with \. Simplest commands are in form \phi, and you can try for example to draw greek letters:  \alpha \beta \gamma .
\( \alpha \beta \gamma \)
Then we have a command with an argument. Arguments are marked by curly braces and can contain just about anything: for example other latex commands. This is why larger formulas seem so complicated. Things are inside things. Square root is a clear example of a command that needs an argument.  \sqrt{\gamma + 5} and  \sqrt{9} are produced by:
\( \sqrt{\gamma + 5} \) and \( \sqrt{9} \)
With fractions we need two arguments and for some constructions even more. Additional arguments are given with additional sets curly braces:  \frac{\sqrt{\gamma + 5}}{9}
\( \frac{\sqrt{\gamma + 5}}{9} \)
Then there are larger 'environments' where things are arranged by their own laws. Arrays are the most often used environments. They can be used as a tables or matrices: You signal the begin and end of an environment with a command. The \begin... equation ... syntax we use to start writing formulas is one environment, and if you are going to draw matrices or other things that need special environments, you'll want to use it, so that the results are not crammed to fit into one line. So..
\begin{equation}
\begin{array}
...array contents ...
\end{array}
\end{equation}
Array as a matrix: (the number of columns is given as a second argument in begin, columns are separated by &:s and rows by \\:s.)
\begin{equation}
\left[
\begin{array}{ c c c }
1 & 2 & \phi   \\
5 & x & \alpha \\
\end{array}
\right]
\end{equation}
 \left[ \begin{array}{ c c c } 1 & 2 & \phi \\ 5 & x & \alpha \\ \end{array} \right]
Arrays as organizers: In cheat sheet you'll find this example which is quite tricky but results are beautiful:
\begin{equation}
f(z) = 
\left\{ 
\begin{array}{rcl} 
\overline{\overline{z^2}+\cos z} & \mbox{for} 
& |z|<3 \\ 0 & \mbox{for} & 3\leq|z|\leq5 \\ 
\sin\overline{z} & \mbox{for} & |z|>5 
\end{array}
\right. 
\end{equation}
 f(z) = \left\{ \begin{array}{rcl} \overline{\overline{z^2}+\cos z} & \mbox{for} & |z|<3 \\ 0 & \mbox{for} & 3\leq|z|\leq5 \\ \sin\overline{z} & \mbox{for} & |z|>5 \end{array} \right.

Additional information

http://www.ctan.org/ -- headquarters of everything about TeX or LaTeX
http://amath.colorado.edu/documentation/LaTeX/tutorial/ -- one LaTeX tutorial. Concentrate on sections about maths, as there are other 'environments' that we do not use here.
http://en.wikipedia.org/wiki/TeX -- Wikipedia links for general information
http://en.wikipedia.org/wiki/LaTeX

There are lots of tutorials out there, probably ones for your language too.


\longrightarrow \heartsuit \longleftarrow

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
MultimediaMaterial