You are not logged in.
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:
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:
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
Just as with sub/superscripts, they can be embedded within other fractions.
5) Special Characters
Special characters include the following:
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:
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:
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:
Gives:
Last edited by Dross (2006-10-10 11:33:44)
Bad speling makes me [sic]
Offline
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
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
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
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:
what could be wrong?
Offline
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
Ok that makes sense, thanks.
Offline
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
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
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:
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:
Last edited by Dross (2006-10-11 22:12:08)
Bad speling makes me [sic]
Offline
Thanks! That's great. Let's see:
Offline
//just a test...
Last edited by krassi_holmz (2006-12-25 12:45:17)
IPBLE: Increasing Performance By Lowering Expectations.
Offline
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
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
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
Latex is getting more and more complex.
Last edited by George,Y (2007-02-24 14:46:00)
X'(y-Xβ)=0
Offline
Latex is getting more and more complex.
Indeed.
Offline
George,Y wrote:Latex is getting more and more complex.
Indeed.
Bad speling makes me [sic]
Offline
What does the slash exclamation point do?
Appears to remove the spaces that go with the f normally??
Last edited by John E. Franklin (2007-02-27 17:12:21)
igloo myrtilles fourmis
Offline
\! removes some space between charachters:
y = m x + c \\\\
y \! = \! m \! x \! + \! c
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
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
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
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
\cos{x}=0\Leftrightarrow x\in\{(n+$$\frac{1}{2}$$)\pi:n\in\mathbb{Z}\}
Offline
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
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