Dave 246 Posted May 29, 2004 This is a short guide to using the new LaTeX system that has been implemented on the boards. First off, for those who don't know what LaTeX is, a short description. LaTeX is, to all intents and purposes, a fully fledged math typesetting system - basically put, you can write math with it. It's a very flexible and hence very advanced piece of software, and the syntax for it is quite complex, but fairly easy to learn for typesetting smaller equations.On scienceforums.net, we've implemented a small LaTeX system to allow you to typeset equations (in other words, cut out all the x^2 stuff and make things easier to read for everyone). The basic principle behind it is this: you have a LaTeX string, and you surround it by [math][/math] tags. I'll come to the syntax of the actual string in a moment.For those who can already use LaTeX (and indeed, those who can't), a few things to note. In the system we've implemented, a tex file is created, surrounding the string you input with a \begin{display} environment so there is no need for $, $, \[ etc. Also note that we've included the standard AMS files for you; if anyone wants any special characters, I'm sure we can probably accommodate your needs.The images are clickable, so you can see the code that was used to make them by clicking.Now that's all out of the way, onto some examples Examples[math]x^2_1[/math] - Indexes (both subscript and superscript) on variables[math]f(x) = \sin(x)[/math] - A simple function.[math]\frac{dy}{dxx} = \frac{1}{1+x^2}[/math] - Example of fractions - you can create small fractions by using \tfrac.[math]\int_{-\infty}^{\infty} e^{-x^2} = \sqrt{\pi}[/math] - A nice integral. [math]\mathcal{F}_{x} [\sin(2\pi k_0 x)](k) = \int_{-\infty}^{\infty} e^{-2\pi ikx} \left( \frac{e^{2\pi ik_{0}x} - e^{-2\pi ik_{0}x}}{2i} \right)\, dx[/math] - a Fourier Transformation, which is rather large. I could go on and on, but I'll go onto explain some of the basic syntax of LaTeX.SyntaxFunctions & General SyntaxBasically put, if you want to write a math equation in LaTeX, you just write it. If you wanted f(x) = 3, then bung that between to math tags and you're done, producing [math]f(x)=3[/math]. Don't worry about extra spaces or carriage returns, because in general LaTeX will ignore them. It does get a little more complex than this, but don't worry about that for now. Remember that any letters you type in will be presumed to be some kind of variable and hence will be italicised.We also have functions to display more complex things like matrices and fractions, and they have the syntax of having a \ before them, usually followed by some kind of argument. For example, \sin will produce the function sin and \frac{num}{denom} will produce a fraction with a specified numerator and denominator. More on these later.Also remember that LaTeX is case sensitive, so \sigma is NOT the same as \Sigma.Subscripts and SuperscriptsThis is perhaps one of the easiest things to do in LaTeX, and one of the most useful. Let's, for the sake of argument, say you wanted to write x^{2}. Then you'd write x^{2}, producing [math]x^2[/math]. Notice that you don't necessarily need the { and } in cases where you only have 1 thing in the index, for example x^2. But it does care if you want to write something like [math]x^{3x+2}[/math]. Subscripts are done similarly, but you use the _ operator instead of ^. If you want both subscript and superscript, then use the syntax x^{2}_{1} - which is equivalent to x_{1}^{2}.Fractions and functionsAs I've mentioned, fractions are generated by using the function \frac{num}{denom}. For example:[math]\frac{1}{3}[/math][math]\frac{7}{x^2}[/math]If you want smaller fractions, you can use \tfrac, to produce things like [math]\tfrac{1}{2}[/math] which will fit into a line nicely without having to seperate it.LaTeX has some nice in-built functions like \sin, \cos, etc. I'm not going to write them all down here, but I'll point you to a website at the end of the document that contains them. Likewise, you can write symbols (such as infinity by using \infty) and Greek letters (e.g. \phi, \Sigma, \sigma, etc)BracketingYou can get all your usual brackets just by typing them straight in; for instance, (, |, [, etc. However, sometimes they won't be the right size, especially if you want to write something like (1/2)^{n}. You can get around this by using the \left and \right commands, and then placing your favourite brackets after them. For instance, to write (1/2)^{n}, we have:[math]\left( \frac{1}{2} \right)^{n}[/math]Integrals, Summations and LimitsIntegrals can be produced by using \int, summations by \sum and limits by \lim. You can put limits on them all in the right places by using the normal subscript/superscript commands. For instance:[math]\int_a^b x^2 \,dx[/math][math]\lim_{n\to\infty} \frac{1}{n} = 0[/math][math]\sum_{n=1}^{\infty}\frac{1}{n^2} = \frac{\pi^2}{6}.[/math]SummaryThere's a lot more things you can do with LaTeX, and I'll try to add to this as time goes by. Have a look at:http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/'>http://www.maths.tcd...ns/LaTeXPrimer/ - the LaTeX primerhttp://omega.albany.edu:8008/Symbols.html'>http://omega.albany....08/Symbols.html - some symbols that you might find useful.If you have any questions about the system, send me a PM and I'll try to help Cheers. 4 Share this post Link to post Share on other sites

NSX 27 Posted May 30, 2004 Can we make that feature like on PhysicsForums where when you click on the LaTeX image, it shows the code? 0 Share this post Link to post Share on other sites

Dave 246 Posted May 30, 2004 In a few days time, I will hopefully be able to implement a clickable image, so that everyone can see the code behind what I've written here. In the meantime, you can view the code by either quoting the post (but please don't hit the reply button!) or by hovering your mouse over the image, which should display the math equation as the alternate title for the image. Already doing it 0 Share this post Link to post Share on other sites

Martin 416 Posted May 31, 2004 testing [math]\frac{a''}{a}= -\frac{4\pi G}{3}(\rho + 3p)[/math] ahhhh 0 Share this post Link to post Share on other sites

NSX 27 Posted May 31, 2004 Already doing it i should read the entire post before posting how are you setting this up? 0 Share this post Link to post Share on other sites

Aeschylus 10 Posted May 31, 2004 I think the first form is preferable to the second form, when using exponents: [math]ds^2 = d{x_0}^2 - d{x_1}^2 - d{x_2}^2 - d{x_3}^2[/math] [math]ds^2 = dx_0^2 - dx_1^2 - dx_2^2 - dx_3^2[/math] 0 Share this post Link to post Share on other sites

Dave 246 Posted May 31, 2004 I have to say I prefer the second form myself, but each to his/her own 0 Share this post Link to post Share on other sites

Cap'n Refsmmat 1344 Posted May 31, 2004 I can't see all of the equations, only about half. And hitting "Show Picture" doesn't work, either... 0 Share this post Link to post Share on other sites

blike 319 Posted May 31, 2004 Do you get a red X or what? They're all working for me :/ 0 Share this post Link to post Share on other sites

Dave 246 Posted May 31, 2004 I can't see all of the equations' date=' only about half.And hitting "Show Picture" doesn't work, either...[/quote'] Try hitting refresh. They don't always work for some reason; I think it's to do with the fact that we're storing the images off-site. 0 Share this post Link to post Share on other sites

Cap'n Refsmmat 1344 Posted May 31, 2004 Thanks! They work now! 0 Share this post Link to post Share on other sites

NSX 27 Posted June 1, 2004 What do you mean? like ... how is it everytime the forums see a [tex] tag, and something inside, they convert it to a latex image? 0 Share this post Link to post Share on other sites

Dave 246 Posted June 1, 2004 Basically I modified vB slightly to add a math tag (which was the easy bit). Then all you have to do is get something like latexrender and modify it a bit to give you the kind of image you want. It's all very clever 0 Share this post Link to post Share on other sites

bloodhound 62 Posted June 2, 2004 just testing [math]ds^2=dt^2-(dx^2+dy^2+dz^2)[/math] [math]\int_a^{\infty} f(x)dx=\lim_{L\to\infty}\int_a^{L}f(x)dx[/math] [math]$Let$ {v_1,v_2,...,v_k}$be the basis set for the vector space$V$which are linearly independent, then it is possible to construct another basis set${e_1,e_2,...,e_k}$from the original basis set, such that the basis vectors in the new basis set are all orthogonal to each other, i.e.{:content:}lt;e_i,e_j>=0$for$ i≠j$ where{:content:}lt;,>$ is the inner product defined on the Vector Space$V$ [/math] 0 Share this post Link to post Share on other sites

bloodhound 62 Posted June 2, 2004 why isn't this script coming out properly? <math>$Let$ {v_1,v_2,...,v_k}$be the basis set for the vector space$V$which are linearly independent, then it is possible to construct another basis set${e_1,e_2,...,e_k}$from the original basis set, such that the basis vectors in the new basis set are all orthogonal to each other, i.e.$<e_i,e_j>=0$for$ i≠j$ where$<,>$ is the inner product defined on the Vector Space$V$ </math> 0 Share this post Link to post Share on other sites

Dave 246 Posted June 2, 2004 We don't use $ as the symbol operator. We use [ math ] and [ /math ] ( without the spaces). 0 Share this post Link to post Share on other sites

bloodhound 62 Posted June 2, 2004 yes but it seems that if u put $stuff$ the output will be text instead of maths for example [math]I am Bloodhound[/math] compared to [math]$I am Bloodhound[/math] 0 Share this post Link to post Share on other sites

Dave 246 Posted June 2, 2004 The correct syntax is just [ math ] x^2 [ /math ] (without the spaces). If you use the $, it will display it as text since the expression is already surrounded by a \begin{display} thing. It's all at the top of the article. 0 Share this post Link to post Share on other sites

Cap'n Refsmmat 1344 Posted June 2, 2004 [math]It does this too? Interesting... nice font.[/math] 0 Share this post Link to post Share on other sites

Dave 246 Posted June 2, 2004 Technically speaking the "proper" way to do it is use \mbox{}, like so: [math]\forall \epsilon > 0 \, \exists \,\delta > 0 \mbox{ such that } |x-c| < \delta \Rightarrow \left| \frac{f(x)-f©}{x-c} - f'© \right| < \epsilon[/math] (that's the definition of differentiability at a point c) 0 Share this post Link to post Share on other sites

J'Dona 11 Posted June 2, 2004 Just going to test the code: [math]e^{j\pi} + 1 = 0[/math] Sweet, thanks dave! This'll make things a little easier By the way, I had no idea that: [math]\int_{-\infty}^{\infty}e^{-x^2} = \sqrt{\pi}[/math] I'll have to remember that. 0 Share this post Link to post Share on other sites

bloodhound 62 Posted June 2, 2004 Ah, i see J'Dona, u must be a physicist. as u used j instead of i. oh yeah, dave, can u corrent my script. i just wanna see what it looks like 0 Share this post Link to post Share on other sites

Dave 246 Posted June 2, 2004 Don't think it works because it's too long; I put a max character limit to stop people typing loads of stuff in and getting a stupidly large image for security purposes. (btw I think I needed to add a dx to that integral) (p.s. use i ) 0 Share this post Link to post Share on other sites

stevem 10 Posted June 3, 2004 oh yeah, dave, can u corrent my script. i just wanna see what it looks like Mix maths and text to give this: Let [math]\{v_1,v_2,...,v_k\}[/math]be the basis set for the vector space V which are linearly independent, then it is possible to construct another basis set [math]\{e_1,e_2,...,e_k\}[/math]from the original basis set, such that the basis vectors in the new basis set are all orthogonal to each other, i.e. [math]<e_i,e_j>=0[/math] for [math]i \neq j[/math] where [math]<,>[/math] is the inner product defined on the Vector Space V That looks fine to me. Don't forget you need to put \ before { and } to tell [math]\LaTeX[/math] that you really mean those. If dave could put a math button to insert [ math] and [ /math] tags then it will be even easier to type. 0 Share this post Link to post Share on other sites