You are not logged in.
555
Offline
555
Offline
555
Offline
e
Offline
@@K2Fsy
Offline
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: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:
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:
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:
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: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:
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:gives:
You can embed sub/superscripts within sub/superscripts, as in
- just remember to use braces where neccessary. The previous example was generated from:.
4) Fractions
Fractions such as
are done using the function: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:
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:
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:Gives:
When the sumation symbol, "\sum", is used with super/subscripts, the text is placed directly above or below the sumation symbol. For example:
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:
Gives:
You can also utilise cube roots, nth 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: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:
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 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: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:Gives:
The code: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.
Offline
20
Offline
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: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:
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:
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:
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: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:
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:gives:
You can embed sub/superscripts within sub/superscripts, as in
- just remember to use braces where neccessary. The previous example was generated from:.
4) Fractions
Fractions such as
are done using the function: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:
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:
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:Gives:
When the sumation symbol, "\sum", is used with super/subscripts, the text is placed directly above or below the sumation symbol. For example:
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:
Gives:
You can also utilise cube roots, nth 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: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:
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 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: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:Gives:
The code: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.
Offline
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: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:
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:
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:
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: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:
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:gives:
You can embed sub/superscripts within sub/superscripts, as in
- just remember to use braces where neccessary. The previous example was generated from:.
4) Fractions
Fractions such as
are done using the function: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:
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:
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:Gives:
When the sumation symbol, "\sum", is used with super/subscripts, the text is placed directly above or below the sumation symbol. For example:
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:
Gives:
You can also utilise cube roots, nth 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: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:
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 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: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:Gives:
The code: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.
Offline
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: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:
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:
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:
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: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:
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:gives:
You can embed sub/superscripts within sub/superscripts, as in
- just remember to use braces where neccessary. The previous example was generated from:.
4) Fractions
Fractions such as
are done using the function: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:
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:
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:Gives:
When the sumation symbol, "\sum", is used with super/subscripts, the text is placed directly above or below the sumation symbol. For example:
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:
Gives:
You can also utilise cube roots, nth 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: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:
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 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: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:Gives:
The code: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.
Offline
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: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:
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:
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:
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: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:
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:gives:
You can embed sub/superscripts within sub/superscripts, as in
- just remember to use braces where neccessary. The previous example was generated from:.
4) Fractions
Fractions such as
are done using the function: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:
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:
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:Gives:
When the sumation symbol, "\sum", is used with super/subscripts, the text is placed directly above or below the sumation symbol. For example:
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:
Gives:
You can also utilise cube roots, nth 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: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:
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 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: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:Gives:
The code: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.
Offline
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: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:
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:
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:
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: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:
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:gives:
You can embed sub/superscripts within sub/superscripts, as in
- just remember to use braces where neccessary. The previous example was generated from:.
4) Fractions
Fractions such as
are done using the function: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:
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:
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:Gives:
When the sumation symbol, "\sum", is used with super/subscripts, the text is placed directly above or below the sumation symbol. For example:
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:
Gives:
You can also utilise cube roots, nth 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: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:
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 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: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:Gives:
The code: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.
Offline
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: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:
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:
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:
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: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:
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:gives:
You can embed sub/superscripts within sub/superscripts, as in
- just remember to use braces where neccessary. The previous example was generated from:.
4) Fractions
Fractions such as
are done using the function: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:
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:
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:Gives:
When the sumation symbol, "\sum", is used with super/subscripts, the text is placed directly above or below the sumation symbol. For example:
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:
Gives:
You can also utilise cube roots, nth 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: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:
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 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: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:Gives:
The code: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.
Offline
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: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:
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:
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:
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: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:
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:gives:
You can embed sub/superscripts within sub/superscripts, as in
- just remember to use braces where neccessary. The previous example was generated from:.
4) Fractions
Fractions such as
are done using the function: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:
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:
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:Gives:
When the sumation symbol, "\sum", is used with super/subscripts, the text is placed directly above or below the sumation symbol. For example:
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:
Gives:
You can also utilise cube roots, nth 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: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:
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 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: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:Gives:
The code: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.
Offline
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: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:
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:
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:
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: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:
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:gives:
You can embed sub/superscripts within sub/superscripts, as in
- just remember to use braces where neccessary. The previous example was generated from:.
4) Fractions
Fractions such as
are done using the function: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:
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:
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:Gives:
When the sumation symbol, "\sum", is used with super/subscripts, the text is placed directly above or below the sumation symbol. For example:
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:
Gives:
You can also utilise cube roots, nth 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: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:
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 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: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:Gives:
The code: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.
Offline
e
Offline