• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

help make a LATEX sticky!

andyandy

anthropomorphic ape
Joined
Apr 30, 2006
Messages
8,377
Ok.....we can have a LaTeX sticky....so this is what i've cobbled together....


What is LaTeX?

[latex] \LaTeX{} [/latex] tags give you text[latex]$ flexibility[/latex]

It's useful for a whole host of desk-top processing commands, but it's especially useful for maths.

The tags you need are
[latex]$[/latex]

and then you simply

[latex]$ insert code here [/latex]

So the basics,

powers

[latex]$ x^3 [/latex] =

[latex]$ x^3 [/latex]

[latex]$ x^{3n} [/latex]

[latex]$ x^{3n} [/latex]

indices

[latex]$ x_3 [/latex]

[latex]$ x_3 [/latex]

[latex]$ x_{3n} [/latex]

[latex]$ x_{3n} [/latex]

division

[latex]$ \frac{a}{b} [/latex] =

[latex]$ \frac{a}{b} [/latex]

[latex]$ \frac{\frac{c}{d} + \frac{e}{f}}{x} [/latex]=

[latex]$ \frac{\frac{c}{d} + \frac{e}{f}}{x} [/latex]

roots

[latex]$ \sqrt{x} [/latex]=

[latex]$ \sqrt{x} [/latex]

[latex]$ \sqrt[3]{x} [/latex]=

[latex]$ \sqrt[3]{x} [/latex]

text
whilst you can write straight into [latex] tags, you lose formatting control...so you can get round this by;

[latex]$ \mbox{ the answer is } \sqrt[3]{x} \mbox{ I think!} [/latex]=

[latex]$ \mbox{ the answer is } \sqrt[3]{x} \mbox{ I think!} [/latex]

integration

[latex] \int 3x dx[/latex]=

[latex] \int 3x dx[/latex]

[latex] \int_0^{\infty} 3x dx[/latex]=


[latex] \int_0^{\infty} 3x dx[/latex]

Sum

[latex]$\sum_{i=0}^n x_i [/latex]

[latex]$\sum_{i=0}^n x_i [/latex]


Greek letters

[latex] \alpha \beta \gamma \Gamma [/latex]=

[latex] \alpha \beta \gamma \Gamma [/latex]


other useful commands

[latex]$ \pi \infty \lim_{x\to 1} [/latex]

[latex]$ \pi \infty \lim_{x\to 1} [/latex]

ok....that's what i can think of, with reference to

http://en.wikibooks.org/wiki/LaTeX/Mathematics

I am a bit of a latex novice - so feel free to correct any coding mistakes too....:)

what else is useful? What should be expanded? etc. etc....
 
Last edited:
And if you want your summations, integration, products, etc. to be extra pretty, you can use /displaystyle. For example, you could turn
latex.php
into
latex.php


One of my favourite reference pages is http://www.forkosh.com/mimetextutorial.html It has a bunch of symbols as well as the commands for different scripts (although I can't seem to get \mathcal to work for me here, despite evidence to the contrary that it works in the thread that Paul A. linked to...)
 
Mathcal works just fine, here:

[latex]$\mathcal{MATHCAL \: WORKS \: JUST \: FINE}$\large{!}[/latex]

:D

Here's the code for the above:

[latex]$\mathcal{MATHCAL \: WORKS \: JUST \: FINE}$\large{!}[/latex]

Mathcal is only defined for capitals (upper case) letters, nothing else. The most common mistake is that people try to write text in lower case or with additional characters and find that mathcal doesn't work with those.

Also make sure you set the default to standard editor in usercp options, the WYSIWG editor screws up the latex when previewed, the standard editor works just as well as the WYSIWG editor and doesn't screw up latex at the same time.
 
I had trouble recently with the \frac directive. Hmmm, but waitaminnit, that was before the site conversion...

[latex]F_{g} = \frac{gmm'}{d^2}[/latex]

ETA: Kewl!!! :D
 
I had trouble recently with the \frac directive. Hmmm, but waitaminnit, that was before the site conversion...

[latex]F_{g} = \frac{gmm'}{d^2}[/latex]

ETA: Kewl!!! :D

You have to use the $ or $$ delimiters to put it into math mode! You should RTFM!!!! (O.K. So I didn't write a FM, but if I had, you should have read it!) :D

The correct code is:

[latex]$$F_{g} = \frac{gmm'}{d^2}$$[/latex]

Which gives:

[latex]$$F_{g} = \frac{gmm'}{d^2}$$[/latex]

The reason why the math mode is not automatic like on some other fora, is because the implementation on here is much more extensive. I left the context open so that you could use all the features of latex, not just math, i.e. itemized lists, tables, diagrams, hieroglyphics... and so on.
 
thanks for the suggestions.....i'll try to canibalise the JREF thread, and the mimetutorial....there's some good stuff on both....i'm learning lots too :)

potential stuff to add

[latex] \sum_{i=1}^n i = \frac{n(n+1)}2 [/latex]

[latex] \sum_{i=1}^n i = \frac{n(n+1)}2 [/latex]

To make sure limits are displayed directly below and above the operator, begin your expression with \displaystyle. For example,

[latex] \displaystyle\sum_{i=1}^n i = \frac{n(n+1)}2 [/latex]

[latex] \displaystyle\sum_{i=1}^n i = \frac{n(n+1)}2 [/latex]


Writing [latex]sin^2\theta+cos^2\theta [/latex] renders
[latex]sin^2\theta+cos^2\theta [/latex]

other useful.....

The easiest way to write a matrix in LaTeX is \begin{matrix} a&b\\c&d \end{matrix} which renders


[latex]$$ \begin{matrix} a&b\\c&d \end{matrix}$$ [/latex]

Surround it with \left( ... \right) to obtain . Alternatively,

\begin{pmatrix} ... \end{pmatrix} automatically surounds the rendered matrix with parentheses.

Matrices are written row-wise, with \\ at the end of each row. Within a row, columns are separated by &. A general m x n matrix is therefore written in the form

\begin{matrix}
a1,1 & a1,2 & . . . & a1,n \\
a2,1 & a2,2 & . . . & a2,n \\
. . . . . . . . . . . . . . . . . . . . . \\
am,1 & am,2 & . . . & am,n
\end{matrix}


[latex]
\begin{table}
\begin{tabular}{lll}
Hydrogen&46.2 cubic inches&= 1 grain\\
Oxygen&23.1&= 8 grains\\
Water(steam)&69.3&= 9 grains\\
\end{tabular}
\end{table}
[/latex]

Table with lines:

[latex]
\begin{table}
\begin{center}
\begin{tabular}{|l|l|l|l|}
\hline
Hydrogen&1&&\\
\hline
Air&14.4&1&\\
\hline
Water&11943&829&1\\
\hline
Platinum&256774&17831&21.5\\
\hline
\end{tabular}
\end{center}
\end{table}
[/latex][/QUOTE]

math expression: $ math tokens $

spaces within dollars signs are ignored.

digits: 0, 1, 2, ...

lowercase Roman italic letters: a, b, c, ...

uppercase Roman italic letters: A, B, C, ...

Roman bold letters: \mathbf{A}, \mathbf{a}, ...

lowercase Greek letters: \alpha, \beta, \gamma, ...

uppercase Greek letters: \Gamma, \Delta, \Theta, ...

interesting symbols: \aleph, \hbar, \partial, \infty, \emptyset, \angle, \forall, \exists

simple binary operators: +, -, \times, /, \ast, \pm (plus/minus)

simple relational operators: =, \ne, <, \le, >, \ge

fences: (, ), [, ], \{, \} (note backslash preceding braces)

absolute value: | x |

subscripts: x_{i+1} (if single digit or letter, no braces required)

superscripts: x^{n-1} (if single digit or letter, no braces required)

accents: \hat{x}, \check, \tilde, \acute, \grave, \dot, \ddot, \breve, bar, \vec

primes: x', x'' (two apostrophes)

arrows: \leftarrow (single), \Leftarrow (double), \rightarrow, \Rightarrow, \leftrightarrow, \Leftrightarrow

stacked fraction: \frac{numerator}{denominator}

sum: \sum_{lower limit}^{upper limit}

product: \prod_{lower limit}^{upper limit}


[latex]
\setlength{\unitlength}{1mm}
\begin{picture}(93,46)
\put( 0,14){\vector(1,0){60}}
\put(61,13){$x$}
\put(20,4){\vector(0,1){37}}
\put(19,43){$y$}
\put(50,34){\circle*{2}}
\put(52,35){$P$}
\multiput(20,34)(4,0){8}{\line(1,0){2}}
\put(14.5,33.5){$y_P$}
\multiput(50,14)(0,4){5}{\line(0,1){2}}
\put(48,11){$x_P$}
\put( 2,8){\vector(3,1){56}}
\put(59,26.5){$x'$}
\multiput(50,34)(1.9,-5.7){2}
{\line(1,-3){1.2}}
\put(52,22){$x_P'$}
\multiput(50,34)(-5.8,-1.933){6}
{\line(-3,-1){3.6}}
\put(12,21){$y_P'$}
\put(22,8){\vector(-1,3){10.5}}
\put(10,41){$y'$}
\end{picture}
[/latex]
 
Last edited:
thanks for the suggestions.....i'll try to canibalise the JREF thread, and the mimetutorial....there's some good stuff on both....i'm learning lots too :)

stuff to add

[latex] \sum_{i=1}^n i = \frac{n(n+1)}2 [/latex]

[latex] \sum_{i=1}^n i = \frac{n(n+1)}2 [/latex]

To make sure limits are displayed directly below and above the operator, begin your expression with \displaystyle. For example,

[latex] \displaystyle\sum_{i=1}^n i = \frac{n(n+1)}2 [/latex]

[latex] \displaystyle\sum_{i=1}^n i = \frac{n(n+1)}2 [/latex]



AAAARRRGGGG!!!!!! Why do I get the impression I'm talking to myself!!!

Andy, PLEASE read the instructions in the latex thread properly. Latex by default is NOT automatically in math mode - I don't know how often I have to say this. If you want to do math, you need to tell latex to go into math mode - the way you do this is by using delimiters at the beginning and end of a math expression. There are various different ones that can be used, but the easiest ones are $$ and $ - the difference is that $$ makes a larger standalone image and $ makes a smaller image for inline use. Your example above is wrong because it's not in math mode - you don't need to use \displaystyle to make it render properly, all you need to do is make sure you are actually in math mode. For example:

[latex]$$ \sum_{i=1}^n i = \frac{n(n+1)}2 $$[/latex]

gives:

[latex]$$ \sum_{i=1}^n i = \frac{n(n+1)}2 $$[/latex]

And,

[latex]$ \sum_{i=1}^n i = \frac{n(n+1)}2 $[/latex]

gives:

[latex]$ \sum_{i=1}^n i = \frac{n(n+1)}2 $[/latex]

The reason why the limits are at the side in the second example is because single $ context is designed to be inserted inline in the middle of text and so the limits are moved so as not to increase the line spacing excessively.

All I did was add the proper math mode delimiters, \displaystyle was NOT necessary.

All of this is explained in the OP of the original latex thread! Latex will often work with equations even when you're not in math mode - but it is not guaranteed to work properly and the behaviour is unpredictable.

P.S. the same applies to use of Mathcal - Mathcal ONLY works properly in MATH mode, it won't work properly if you are not in math mode.
 
AAAARRRGGGG!!!!!! Why do I get the impression I'm talking to myself!!!

Andy, PLEASE read the instructions in the latex thread properly. Latex by default is NOT automatically in math mode - I don't know how often I have to say this.

goodness....maybe you should calm down :rolleyes:

this thread is a work in progress in order to produce a decent sticky - if you have constructive comments to make, then that's great - you obviously know a great deal more about latex than most.....but there's no need to rant and rave....:)

FWIW that description was cut and pasted direct from http://www.forkosh.com/mimetextutorial.html
 
Last edited:
[latex]
\setlength{\unitlength}{1mm}
\begin{picture}(93,46)
\put( 0,14){\vector(1,0){60}}
\put(61,13){$x$}
\put(20,4){\vector(0,1){37}}
\put(19,43){$y$}
\put(50,34){\circle*{2}}
\put(52,35){$P$}
\multiput(20,34)(4,0){8}{\line(1,0){2}}
\put(14.5,33.5){$y_P$}
\multiput(50,14)(0,4){5}{\line(0,1){2}}
\put(48,11){$x_P$}
\put( 2,8){\vector(3,1){56}}
\put(59,26.5){$x'$}
\multiput(50,34)(1.9,-5.7){2}
{\line(1,-3){1.2}}
\put(52,22){$x_P'$}
\multiput(50,34)(-5.8,-1.933){6}
{\line(-3,-1){3.6}}
\put(12,21){$y_P'$}
\put(22,8){\vector(-1,3){10.5}}
\put(10,41){$y'$}
\end{picture}
[/latex]

Andy,

That is very cool. :)

Gene
 
Andy,

That is very cool. :)

Gene

i'd love to take credit for that.....but it's copied from a Pragmatist post.....

[latex]
\setlength{\unitlength}{1mm}
\begin{picture}(93,46)
\put( 0,14){\vector(1,0){60}}
\put(61,13){$x$}
\put(20,4){\vector(0,1){37}}
\put(19,43){$y$}
\put(50,34){\circle*{2}}
\put(52,35){$P$}
\multiput(20,34)(4,0){8}{\line(1,0){2}}
\put(14.5,33.5){$y_P$}
\multiput(50,14)(0,4){5}{\line(0,1){2}}
\put(48,11){$x_P$}
\put( 2,8){\vector(3,1){56}}
\put(59,26.5){$x'$}
\multiput(50,34)(1.9,-5.7){2}
{\line(1,-3){1.2}}
\put(52,22){$x_P'$}
\multiput(50,34)(-5.8,-1.933){6}
{\line(-3,-1){3.6}}
\put(12,21){$y_P'$}
\put(22,8){\vector(-1,3){10.5}}
\put(10,41){$y'$}
\end{picture}
[/latex]


i wouldn't know where to even begin with that code :D

but yes, it is very cool :)
 
Last edited:
goodness....maybe you should calm down :rolleyes:

this thread is a work in progress in order to produce a decent sticky - if you have constructive comments to make, then that's great - you obviously know a great deal more about latex than most.....but there's no need to rant and rave....:)

FWIW that description was cut and pasted direct from http://www.forkosh.com/mimetextutorial.html

We'll he did make the point about the delimiters in his post in this thread and in the original announcement thread: http://www.internationalskeptics.com/forums/showthread.php?t=49008

And since Pragmatist developed this implementation of latex I think we can safely assume he knows more about it than anyone else..... ;)
 
Darat,

You would hope so. That assumtion ignores the idea of being beat at your own game. I've experienced that.
Latex is a pretty neat tool. Thanks for the work, Pragmatist.

Gene

And since Pragmatist developed this implementation of latex I think we can safely assume he knows more about it than anyone else..... ;)
 
We'll he did make the point about the delimiters in his post in this thread and in the original announcement thread: http://www.internationalskeptics.com/forums/showthread.php?t=49008

And since Pragmatist developed this implementation of latex I think we can safely assume he knows more about it than anyone else..... ;)

No, there was no point made about the specific difference between $ and $$ in the earlier post in this thread, and only a cursory mention of it in the original announcement thread. I did use delimiters in my OP for \sum - i just didn't realise that $ and $$ would be responsible for the difference between

[latex]$\sum_{i=0}^n x_i $[/latex]

and

[latex]$$\sum_{i=0}^n x_i $$[/latex]

hence when i used a linked site, which provided a method for creating the latter effect, i assumed that this was the best way to do it and pasted their explanation. I don't believe that that was especially unreasonable :)
 
Last edited:
No, there was no point made about the specific difference between $ and $$ in the earlier post in this thread, and only a cursory mention of it in the original announcement thread. I did use delimiters in my OP for \sum - i just didn't realise that $ and $$ would be responsible for the difference between

...snip...

Original thread:

As a general guide to using it for equations, please note that equations must be enclosed within an equation context block. Having said that, it may work without a proper context, but it won't work consistently and what is displayed may not be what you want! The recommended default context is {math} i.e.:

\begin{math} \end{math} - synonymous with an expression enclosed between $$ and $$.

Here is an example: [latex]$$ \frac{1}{\sqrt{1-\frac{v^2}{c^2}}} $$[/latex]

Which looks like this when rendered:

$$ \frac{1}{\sqrt{1-\frac{v^2}{c^2}}} $$

Inline and reduced expressions can be generated using the single $ context. I'll give examples later.

That's it for the moment. I'll post more examples later on, please look at the code and it'll give you an idea of how to do things.

This thread:

You have to use the $ or $$ delimiters to put it into math mode! You should RTFM!!!! (O.K. So I didn't write a FM, but if I had, you should have read it!)
 
Andy,

It's always a good idea to give credit when you're plagiarizing. It puts the blame where it belongs. :)

What does /display style do?

Gene
 
A quick google found that erroneous information about /display style.

[latex]\displaystyle $\sum_{n=0}^\infty x_n$[/latex]
As another example, the limits on a summation symbol are normally placed below and above the symbol in display style and in normal sub and superscript position in textstyle. One could force the below/above placement in running text by using:

  • \displaystyle $\sum_{n=0}^\infty x_n$
The site is Help On LaTeX.

Gene
 
Note to authors: If you are planning to publish your book, do not use the LaTeX picture environment to draw figures. The poor production manager* will almost certainly have to have your figures redrawn.

\displaystyle is a declaration that specifies that the rest of the current math group should be set in "display style," which is the style TeX uses for math displays (as opposed to inline math). It is unnecessary in a math display enclosed in $$; it is sometimes useful in inline math to make the inline math look like it is displayed.

If you do not know the difference between a TeX command and a declaration, please find out. :D

~~ Paul

* e.g., me
 

Back
Top Bottom