Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**Dross****Member**- Registered: 2006-08-24
- Posts: 325

Often on this forum you will see equations embedded into the text of posts. Some are quite complex, others are simple. They are not produced by magical elves that live in the poster's computer - they are produced using a typesetting language called Latex (often written LaTeX or , but pronounced as "Latec"), and what is produced might look like this:

you have to preceed that character with a backslash, "". The above was produced using:

Note that you can attatch both a sub- and superscript to the same charachter as in the above example.

are done using the function:

They are input using commands - words preceeded by backslash charachters. For example, typing "\pi" would output , "\sum" would produce , etc. A fairly thorough list of symbols can be found here.

You can also utilise cube roots,*n*th roots. To do this, you still use the "\sqrt" command, but you put the expression you want before the root in square braces before the curled braces, so would be given by "\sqrt[a]{b}". The expression in the square braces, as well as in the curly braces, can be as complicated as you like. So:

Dynamic braces provide a "fix" for this, so your output can look like this instead:

The above braces were produced using the "\left(" command for the opening brace, and the "\right)" command for the closing brace. This works in a similar fasion for square braces, "[]" and straight braces are treated the same, "||". If you want to produce dynamic curled braces, you still have to put a backslash before you type in the brace symbol itself (the same as with normal braces), like "\left\{" and "\right\}".

You can "nest" braces within braces, but dynamic braces*must* be paired up (each opeing brace must have a closing brace and vice versa, though they do not have to be of the same type) or you will get an error as an output. If you wish to only have an opening - or closing - brace next to an expression, you can use one of the null braces, which are "\left." and "\right.". So, for example:

The code:

Also note that, although it's the case in the above examples, the number of rows in your matrix does not need to be the same as the number of columns. Arrays can be tricky to get the hang of as they can become fairly cumbersome quite easily, but take your time getting to grips with the basics and you'll soon master them.

or even:

Latex itself is actually designed for writing whole documents - you can set out paragraph structure, tables, footnotes and all sorts of other things that normally go into a text document. This forum, however, borrows some of the Latex language, specifically that part used for typesetting mathematical equations.

This post will give you an introduction to the basics of Latex and is looseley grouped into two parts. The first two chapters cover the basic syntax (what the input should be like) and structure for Latex. This is obviously the sort of stuff you need to know before you can use Latex, so do take the time to look at the examples and see if you can understand what's going on. After the syntax has been covered, all that's left is the specifics of what you can do with Latex - how to insert symbols, equations, text and so forth, and this is the subject of the remaining chapters.

**1) Using LaTeX**

To use Latex on this forum, you have to place the Latex code between opening and closing math tags - you would type something in the format that's in the code box:

`[math]<Latex commands go in between these tags>[/math]`

Note that normally, writing the above would have made something that looks like this:

the only reason it didn't is because it's in the code box - to get the output for the following examples, type exactly what you see inside the code boxes, remembering that Latex is case sensitive.

Two important things about how Latex will format your equations:

1) It ignores spaces, and spaces characters how it thinks best - so you can spread out the comands you type to make them easier to read whilst you are typing, but they will produce the same output.

2) Latex also ignores carriage returns, where you start a new line - to start a new line in Latex, use the command:

`\\`

For example, the following two codes will both give the same output:

```
[math]
v = u + a t \\
F = m a
[/math]
```

`[math]v=u+at\\F=ma[/math]`

Shown here:

and:

Note that the first line will be indented by default - if you want to remove this, simply place the "\" command before the first line. So:

```
[math]
\\ v = u + a t \\
F = m a
[/math]
```

Gives:

**2) Basic Expressions**

As you've seen from above, basic expressions are typed in exactly as you would do when normally typing. You can use brackets, equals, minus, vertical bars "|", and so on.

Some things you cannot use directly are curled braces, like "{" or "}". Other characters that cannot be directly used are:

`# $ % & ~ _ ^ \`

as these all mean something special in the Latex language. If you want your output to display one of these characters, for example:

you have to preceed that character with a backslash, "". The above was produced using:

`[math]a = 50 \%[/math]`

The one exception to this is if you want to output the backslash character itself. This is done using the following command:

`\backslash`

.

**3) Superscript and Subscript**

The superscript and subscript commands in Latex are "^" and "_" respectively. So the following code will give the output below:

`[math]x_1 = y^2 = z^4_1[/math]`

Note that you can attatch both a sub- and superscript to the same charachter as in the above example.

The superscript and subscript characters normally just read the next character along, then go back to normal text formatting. For example, typing x_ijk in your code would give you

. To include more than one character, enclose them in curly braces "{" and "}". So:`[math]x_{ijk}[/math]`

gives:

You can embed sub/superscripts within sub/superscripts, as in

- just remember to use braces where neccessary. The previous example was generated from:`[math]e^{x^{2_i}}[/math]`

.

**4) Fractions**

Fractions such as

are done using the function:

`[math]\frac{numerator}{denominator}[/math]`

Just as with sub/superscripts, they can be embedded within other fractions.

**5) Special Characters**

Special characters include the following:

They are input using commands - words preceeded by backslash charachters. For example, typing "\pi" would output , "\sum" would produce , etc. A fairly thorough list of symbols can be found here.

**6) Text in Latex**

Text can be input in math mode, so you don't have to come out of it to say something. Text is done within the "\mbox{}" command, so:

`[math]V_{sphere} = \frac{4}{3} \pi r^3 \mbox{ is a formula for the volume of the sphere with radius }r[/math]`

Would give an output of:

**7) Special Functions - Trigonometry, Limits, Integrals, Sums and Roots**

Here are some special functions that deserve some special treatment.

First of all, basic trig functions - if you were to write just "cos x" in part of your code, it would look a bit funny. Like this:

. However, by using the special symbol "\cos", the cos in the output will not be in italics, it will look like this: . The same applies to tan, sin, and some other functions, as listed in the list of symbols, which can be found here.Note that, if you use the "\lim" function followed by a subscript, the subscript will be placed directly underneath the "lim" text when it is output. For example:

`[math]\lim_{x \rightarrow \infty} \frac{1}{x} = 0[/math]`

Gives:

Now onto integrals. The text "\int" will give an integral sign,

, which can then be used with super/subscripts in the normal way to give boundaries. For example:`[math]\int_0^{\pi} \cos x dx = 0[/math]`

Gives:

When the sumation symbol, "\sum", is used with super/subscripts, the text is placed directly above or below the sumation symbol. For example:

`[math]\sum_{n=0}^{\infty} n[/math]`

Gives:

Roots can be done using the "\sqrt{}" command, where whatever you want to contain within the square root sign goes in the curled braces. For example:

`[math]r = \sqrt{ x^2 + y^2 }[/math]`

Gives:

You can also utilise cube roots,

`[math]r^{ \frac{ 1 }{ n^2 + 2 } } = \sqrt[ n^2 + 2 ]{r}[/math]`

Gives:

**8) Dynamic Braces**

Dynamic braces are handy when you have large fractions or large symbols (e.g. integrals, sums, etc). They automatically adjust to the size they should be. If you wanted braces around a fraction, you would normally just type something like:

`[math]( \frac{n+2}{3} )[/math]`

But this looks mildly strange, like this:

Dynamic braces provide a "fix" for this, so your output can look like this instead:

The above braces were produced using the "\left(" command for the opening brace, and the "\right)" command for the closing brace. This works in a similar fasion for square braces, "[]" and straight braces are treated the same, "||". If you want to produce dynamic curled braces, you still have to put a backslash before you type in the brace symbol itself (the same as with normal braces), like "\left\{" and "\right\}".

You can "nest" braces within braces, but dynamic braces

`[math] \left. \frac{ n^2 + n}{ n^2 - n} \right\} [/math]`

Gives:

**9) Matrices**

Matrices in Latex are done as arrays inside dynamic braces (see part (8), above). (They do not *have* to be done inside braces, but they almost always are. Either way, you get to choose what type of braces to put them in, if any.)

When you type in your Latex code, first you'll put an opening brace (if you so wish) and then use the command "\begin{array}".

Next, you have to define how many columns you want, and whether you want them aligned by the left, right, or center. The alignment is only important when you have equations and other long-winded expressions as elements in your matrix, for the following examples we'll keep everything aligned to the center for simplicity.

To define how many columns you want, use an opening brace, followed by some letters - use "r", "l" or "c" for each column, indicating how you wish to align each column. For example, if you wanted a matrix with five columns, all aligned to the centre, the opening statement for your matrix will look like this:

```
\left(
\begin{array}{c c c c c}
...
```

If you wanted three columns with the first two aligned to the right, and the last one aligned to the center, you'd use "{r r c}" instead of the "{c c c c c}" command above.

Now we start putting elements into our array. The first element that you put in will go into the first row of the first column. You then go along the row, putting elements in subsequent columns, seperating each element with an "&" symbol. You then indicate that you're moving onto the next row by using a double backslash "\" command. After you've entered the last element there is no need to close it with a "&" or "\", simply use the "\end{array}" command and, if applicable, close your braces.

Here's two examples. Bear in mind that the formatting that's going into the code (the carriage returns and spaces that the user puts in, not the "\" and "&" commands) are for ease of reading only - you could take them all out and have one long string of text if you wanted. It would look messy and if you made a mistake, it'd be hard to spot, but Latex would give the same output.

The code:

```
[math]
\left(
\begin{array}{cc}
a & b \\
c & d
\end{array}
\right)
[/math]
```

Gives:

The code:

```
[math]
\left|
\begin{array}{c c c}
\lambda - 1 & 4 & -3 \\
5 & \lambda + 6 & 7 \\
-8 & 4 & \lambda - 2
\end{array}
\right|
[/math]
```

Gives:

Also note that, although it's the case in the above examples, the number of rows in your matrix does not need to be the same as the number of columns. Arrays can be tricky to get the hang of as they can become fairly cumbersome quite easily, but take your time getting to grips with the basics and you'll soon master them.

*Last edited by Dross (2006-10-10 11:33:44)*

Bad speling makes me [sic]

Offline

**pi man****Member**- Registered: 2006-07-06
- Posts: 251

Just playing around here to try it out. Feel free to delete this in the efforts of tidiness.

`x^2 + y^2 = z^2 \mbox { sure looks nicer than x**2 + y**2 = z**2}`

Is there any easy way to see what your reply will look like before you submit it?

Offline

**Dross****Member**- Registered: 2006-08-24
- Posts: 325

justlookingforthemoment wrote:

I just changed all the 'charachters' in your post to 'characters'. If you actually meant to write 'charachters' in the first place, I will happily change them all back, and sorry if this is what you were intending!

Ah, no... that's just my rubbish spelling! Thanks for changing it so I look less of a fool

And Pi Man - next to the "submit" button when you go to post, there's a button that says "preview". As the name suggests, it'll give you a preview of your post, though it won't go up on the forum and you can still edit it.

I've still got some more stuff to do with this - I've been a little bogged down of late, but I should be able to get some more stuff put down.

Note to self: how to do arrays!

Bad speling makes me [sic]

Offline

**Dross****Member**- Registered: 2006-08-24
- Posts: 325

**Practice Using/Abusing LaTeX!**

Here are some examples for you to practice using Latex. Simply reply to this post, and you can then start a new post - no need to actually post what you practice, though, all you need to do is press the "preview" button and you'll see what your post will look like, and you can mess around to your heart's content!

One other **very handy hint:** this forum has a very handy feature, that when a Latex output appears in a post, you are able to see the code that produced the output simply by clicking on the output itself. Try and copy the outputs given below by replying/previewing a post. You don't have to post them, and you don't have to check that your code is the same as my code - indeed, they may in some cases differ signifigantly, the important thing is that the *outputs* are the same.

Well, here goes:

1)

2)

(note: command for

is "\pi")3)

4)

5)

6)

7)

8)

9)

(note - command for

is "\to" or "\rightarrow")10)

11)

(note - command for

is "\infty")12)

(note - command for

is "\ldots")13)

[note: more to come soon - watch this space!]

*Last edited by Dross (2006-10-16 20:36:37)*

Bad speling makes me [sic]

Offline

**polylog****Member**- Registered: 2006-09-28
- Posts: 162

Thanks for this great tutorial, hope its ok to 'practice' on this thread.

But i wonder, im getting some odd behaviour: if i add lots of newlines inside the math tag, the interpreter gives me something like 'math?' in latex font. e.g. this does not work because of the newlines inside the math tag:

```
[math]
e^{i\theta} = cos\theta + i\sin\theta\\
\cos\theta = \frac{e^{i\theta} + e^{-i\theta}}{2}\\
\sin\theta = \frac{e^{i\theta} - e^{-i\theta}}{2i}\\
[/math]
```

what could be wrong?

Offline

**Dross****Member**- Registered: 2006-08-24
- Posts: 325

Ah yes, I forgot to mention that. You simply cannot put blank lines in between the math tags!

Also, yes, when the output given is:

It simply means there is an error somewhere in your code.

Bad speling makes me [sic]

Offline

**polylog****Member**- Registered: 2006-09-28
- Posts: 162

Ok that makes sense, thanks.

Offline

**Dross****Member**- Registered: 2006-08-24
- Posts: 325

**Just added, hot-off-the-press sections to the original post above:**

1) Roots (tagged on the end of the "special functions" section)

2) Dynamic braces

3) Matrices

I think that's pretty much everything covered. Is there anything anyone thinks should be included? Any LaTeX old-hands spot something I've missed out? Has anybody seen something in a post and wondered how it's done? Or are they wondering how they *would* do something if they needed to? Anything need clarifying/clearing up?

Please let me know!

By the way, what are word censors, pray tell?

*Last edited by Dross (2006-10-10 11:41:31)*

Bad speling makes me [sic]

Offline

**polylog****Member**- Registered: 2006-09-28
- Posts: 162

Could you post an example of creating piecewise functions? None of the various ways I've found online for creating these seems to work here!

Offline

**Dross****Member**- Registered: 2006-08-24
- Posts: 325

A peicewise function is done using two of the techniques explained above, namely arrays and dynamic braces.

1) Start with an open curled brace (command "\left{")

2) Open an array with two columns

3) Put the first function in the first column of the first row, then the condition in the second column of the first row

4) Repeat the last step for subsequent rows, as many as you like, until you've described your desired peicewise function

5) Close the array

6) **Remember** to close your brace with a null brace (command "\right.")

For example, to produce:

The following code is used:

```
[math]f(x) = \left\{
\begin{array}{c l}
1 & x\mbox{ rational} \\
0 & x\mbox{ irrational}
\end{array}
\right.
[/math]
```

Note the second column of the array is alligned to the left, so the conditions are aligned all "nice".

To produce:

The following code was used:

```
[math]g(x) = \left\{
\begin{array}{c l}
x^2 + x + 1 & x \in (-1,0]\\
x^2 + x & x \in (0,1)\\
x^2 & x \not\in (-1,1)
\end{array}
\right.
[/math]
```

*Last edited by Dross (2006-10-11 22:12:08)*

Bad speling makes me [sic]

Offline

**polylog****Member**- Registered: 2006-09-28
- Posts: 162

Thanks! That's great. Let's see:

Offline

**krassi_holmz****Real Member**- Registered: 2005-12-02
- Posts: 1,905

//just a test...

*Last edited by krassi_holmz (2006-12-25 12:45:17)*

IPBLE: Increasing Performance By Lowering Expectations.

Offline

**luca-deltodesco****Member**- Registered: 2006-05-05
- Posts: 1,470

Another useful thing to know, is that '\!' will clear space between objects, and '\ ' will add space, for example:

` \int\int\int`

` \int\!\!\!\int\!\!\!\int`

` \int\ \ \int\ \ \int`

*Last edited by luca-deltodesco (2007-02-05 06:30:26)*

The Beginning Of All Things To End.

The End Of All Things To Come.

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

Try this parent directory and near the bottom is "symbols.pdf"

http://www.andy-roberts.net/misc/latex/tutorial9/

or

http://www.andy-roberts.net/misc/latex/tutorial9/

The pdf goes from page 20 to 27.

188234 bytes is the size of the pdf, if you right click and save target as.

*Last edited by John E. Franklin (2007-02-24 12:56:33)*

**igloo** **myrtilles** **fourmis**

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

Here's a text file of many of them from somewhere's else.

http://www.twiki.org/p/pub/Support/MathModePluginRenderingInTable/math-mode-symbols-overview.txt

or same as

http://www.twiki.org/p/pub/Support/Math … erview.txt

And here's a fun converter to graphics.

http://hausheer.osola.com/latex2png

or click same

http://hausheer.osola.com/latex2png

And here's LOTS of math symbols in DIFFERENT pdf, many the same probably.

http://amath.colorado.edu/documentation/LaTeX/Symbols.pdf

or click same

http://amath.colorado.edu/documentation … ymbols.pdf

*Last edited by John E. Franklin (2007-02-24 13:41:32)*

**igloo** **myrtilles** **fourmis**

Offline

**George,Y****Member**- Registered: 2006-03-12
- Posts: 1,315

Latex is getting more and more complex.

*Last edited by George,Y (2007-02-24 14:46:00)*

**X'(y-Xβ)=0**

Offline

**JaneFairfax****Member**- Registered: 2007-02-23
- Posts: 6,868

George,Y wrote:

Latex is getting more and more complex.

Indeed.

Offline

**Dross****Member**- Registered: 2006-08-24
- Posts: 325

JaneFairfax wrote:

George,Y wrote:Latex is getting more and more complex.

Indeed.

Bad speling makes me [sic]

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

What does the slash exclamation point do?

Appears to remove the spaces that go with the f normally??

Strange spaceing before a Q? or first letter?

*Last edited by John E. Franklin (2007-02-27 17:12:21)*

**igloo** **myrtilles** **fourmis**

Offline

**Dross****Member**- Registered: 2006-08-24
- Posts: 325

\! removes some space between charachters:

```
y = m x + c \\\\
y \! = \! m \! x \! + \! c
```

(remember latex ignores white-space)

You can put more spacing between charachters using (in increacing order of the amount of space it'll give you) "\,", "\:", "\;", "\quad" and "\qquad".

`a b \, c \: d \; e \quad f \qquad g`

Edit: Oh yeah, strange spacing is before the first line, but only if there's more than one line

It's just a forum thing - put a double-backslash as the first thing in your math-tags and it's not a problem.

*Last edited by Dross (2007-02-28 04:27:44)*

Bad speling makes me [sic]

Offline

**JaneFairfax****Member**- Registered: 2007-02-23
- Posts: 6,868

You can even specify exactly how much spacing you want. For example, if you want exactly 30 mm of white space,

`\hspace{30mm}`

Thus:

*Last edited by JaneFairfax (2007-02-28 10:18:56)*

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

How come my

as the beginning and end of the sentence when I first post it, but then later it might.*Last edited by John E. Franklin (2007-03-01 18:05:15)*

**igloo** **myrtilles** **fourmis**

Offline

**JaneFairfax****Member**- Registered: 2007-02-23
- Posts: 6,868

Ive just learnt a handy little trick. You can use the double-dollar $$ to make part of your text smaller. For example, if you type

\cos{x}=0\Leftrightarrow x\in\{(n+\frac{1}{2})\pi:n\in\mathbb{Z}\}

you get

It looks fine except that the fraction appears a little oversized in the formula. To make it smaller and the formula neater, put $$ before and after the code for the fraction:

\cos{x}=0\Leftrightarrow x\in\{(n+$$\frac{1}{2}$$)\pi:n\in\mathbb{Z}\}

Offline

**luca-deltodesco****Member**- Registered: 2006-05-05
- Posts: 1,470

wow didn't know about that, ive also learnt how to do the proper Z now using \mathbb{#}

The Beginning Of All Things To End.

The End Of All Things To Come.

Offline

**Zhylliolom****Real Member**- Registered: 2005-09-05
- Posts: 412

I have a question, but first I must know this: does anyone here use Miktex and WinShell?

Also, isn't this kind of a weird forum for this thread to be in? I always have to think for a second to remember where to find this topic.

Offline