LaTeX Mastering LaTeX Equations: A Comprehensive Guide for Beginners on Physics Forums

  • Thread starter Thread starter Redbelly98
  • Start date Start date
AI Thread Summary
The discussion focuses on improving the LaTeX guide for beginners on Physics Forums, emphasizing the need for updated resources and clearer explanations. Participants suggest starting with basic instructions for posting simple equations using [itex] and [tex] tags, and then progressing to more complex topics like matrices and multi-line code. Key issues include addressing the 50-character bug that disrupts LaTeX formatting and clarifying the differences between itex and tex tags. There is also a call for better documentation, including a comprehensive symbol list and clearer examples of LaTeX usage. Overall, the thread aims to enhance the learning experience for users new to LaTeX.
Redbelly98
Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Messages
12,178
Reaction score
186
[EDIT: https://www.physicsforums.com/showthread.php?p=3977517#post3977517" for the LaTeX FAQ that resulted from the following discussion.]

It would be good to replace https://www.physicsforums.com/showthread.php?t=386951" with something more up-to-date. I know Fredrik has thoughts on this. Sorry that I don't have time to come up with a first draft, but I am thinking the entry would:
  • Begin, in the first few lines, with the very basics. This is so complete novices can find out how to post very basic equations and symbols.
  • Then link to, or even explain in more detail, how to do more interesting stuff -- for example matrices, multiple-line code, etc.

The opening simple explanation could be what I wrote in Forum Feedback:
Redbelly98 said:
Members often ask how to make the nice looking math equations that they see in posts at Physics Forums. To do this, simply type equations or symbols between [itex] and [/itex]. For example, [itex] \lambda^2 [/itex] will result in \lambda^2.
... and right away it is clear how to make Greek letters and superscripts. (Well, lower-case Greek.)
 
Last edited by a moderator:
Physics news on Phys.org


Ah, I found an earlier post by Fredrik that might be useful here. https://www.physicsforums.com/showthread.php?t=386951" refers to my Forum Feedback post; "Borek's post...should be deleted" has been deleted.
Fredrik said:
That thread could use some cleanup. Borek's post about the old preview bug should be deleted. It's weird to explain multiple lines by linking to page 19 of 49 of an old locked thread filled with lots of irrelevant information and broken LaTex code. (I would just link to a web page that explains the align environment). Those are just examples. I'm reluctant to link to this thread myself because of all the problems with it.

The thread should at least explain the difference between itex and tex tags (you could e.g. use my example below), link to the comprehensive LaTeX symbol list, mention the 50 character bug, mention the quick edit refresh bug, and mention that the best way to learn is to click on the quote button every time you see a post that makes you think "I wonder how he did that". (OK, I see now that the "how to latex" document actually does that last thing).

Example of itex vs tex: The function \sin:\mathbb R\rightarrow\mathbb R is defined by \sin x=\sum_{n=0}^\infty \frac{(-1)^n}{(2n+1)!}x^{2n+1}, for all x\in\mathbb R. Note that the comma must be placed inside the tex tags, and that you shouldn't type any line breaks.

The "how to latex" pdf should also be updated. It doesn't mention itex tags, fails to mention that \\ only works in specific environments (like align), falsely claims that tex tags are equivalent to "dollar sign, LaTeX code, dollar sign" in a LaTeX document. (This would give you a result equivalent to itex. You need two dollar signs before and after the code to get a result equivalent to tex). The pdf explains some things in awkward ways. For example matrices: \Lambda=\gamma\begin{pmatrix}1 & -v\\ -v & 1\end{pmatrix} I also think people would prefer to use the cases environment instead of arrays: \chi_{\mathbb Q}(x)=\begin{cases}1 &\text{if }x\in\mathbb Q\\ 0 &\text{if }x\notin\mathbb Q.\end{cases} The displaystyle command is explained badly. It's used to prevent LaTeX from formatting the math the way it normally would when the math image is to appear on a line that also includes text. Compare \sum_{k=0}^n x_k to {\displaystyle \sum_{k=0}^n x_k}. The latter code includes a "displaystyle". Note the positions of the curly brackets. They don't go where you'd normally put them. (Compare it with the source code for this image: \sqrt{x^2}).
 
Last edited by a moderator:


How do I work with LaTeX here?
Those fancy mathematical symbols are being made with something called LaTeX. Typing LaTeX-symbols in physicsforums is fairly easy. You just need to type the equations or symbols between [itеx] and [/itеx]. For example,
Code:
[itex] \lambda^2 [/itex]
will yield \lambda.

Alternatively, one can also type equations between [tеx] and [/tеx]. These tags do basically the same thing as itex, with the only example that they put everything on a separate line. So type
Code:
[tex] \lambda^2 [/tex]
yields \lambda^2

For the ones already faamiliar with LaTeX: the [itеx] brackets are analohous to $, and the [tеx] brackets are $$.

The easiest way to learn LaTeX is to see what others have done. If you see a post with a nice equation in it, just click QUOTE (at the bottom of the post) to see what the auther did.​

Important bug:
LaTeX in this forum has a quite important bug: after each 50 typed characters, it will automatically insert a space. This can screw up some LaTeX formulas. So be sure to insert a space regularly.
[/INDENT]
A very short introduction to LaTeX

So far, we know how to type in LaTeX, but we do not know the specific formulas. We will now introduce some of the more common formulas. A comprehensive list of formulas can be found at mirror.ctan.org/info/symbols/comprehensive/symbols-a4.pdf

Sadly, not all symbols are being supported by mathjax. To see a full list of suppoerted symbols, see http://www.mathjax.org/docs/1.1/tex.html

Now, we will introduce some easy formulas:

Special characters The following characters have a special meaning in LaTeX: # $ % { } _ ^ \ ~
The first six can be printed by \# \$ \% \{ \} \_

Lines and text \\ starts a new line, \ includes a space, \text{...} included text.

Note: \\ only works in some environments, such as array, align,,...

fractions Fractions can be included by typing \frac{a}{b}. For example,

Code:
[itex]
\frac{2}{4}
[/itex]

This will yield \frac{2}{4}

roots Square roots can be included by typing \sqrt. For example,

Code:
[itex]
\sqrt{16}
[/itex]

This will give \sqrt{16}. Arbitrary n-th roots can be gived by \sqrt[n]. For example,

Code:
[itex]
\sqrt[4]{16}
[/itex]

This will give \sqrt[4]{16}

Subscripts and superscript To type subscripts, just include _ For example
Code:
[itex]
x_y
[/itex]
will give x_y. For superscripts, use ^ For example,
Code:
[itex]
x^y
[/itex]
will give x^y

It might be necessary to include the brackets { }. For example,
Code:
[itex]
x^{x+y}
[/itex]
will give x^{x+y}. Typing
Code:
[itex]
x^x+y
[/itex]
will give x^x+y.

Subscripts and superscripts work with integrals, limits, summations as well. For example,
Code:
[tex]
\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/tex]
will give us

\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}

If you do the same thing in itex, then you get \lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}. You notice that the subscrpt is written next to the limit instead of beneath it. To solve this, begin the text with \displaystyle. For example, typing
Code:
[itex]
\displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/itex]
will give \displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}

Delimiters The symbols ( ), [ ], \{ \} will give (~),[~], \{~\}.
If you want larger delimiters, then you will have to include \left and \right. For example
Code:
[tex]
\left( \begin{array}{cc} a & b\\ c & d\end{array} \right)
[/tex]
will give

\left( \begin{array}{cc} a & b\\ c & d\end{array} \right)

If you only want a left larger delimiter, then you need to include \left. or \right. For example
Code:
[tex]
\left. \begin{array}{cc} a & b\\ c & d\end{array} \right)
[/tex]
will give

\left. \begin{array}{cc} a & b\\ c & d\end{array} \right)

Frequently used symbols A nice list of frequently used symbols can be found at http://www.artofproblemsolving.com/Wiki/index.php/LaTeX:Symbols

Typing arrays and matrices An array can easily be typed by \bеgin{array} \еnd{array}. After \bеgin{array}, you have to specify the number of columns. An array with 5 columns would be typed as \bеgin{array}{ccccc} \еnd{array}.

Columns in the array are separated by &, and rows are separated by \\.

An example:
Code:
[tex]
\left(
\begin{array}{cccc}
1 & 2 & 2 & 4\\
5 & 6 & 7 & 8
\end{array}
\right)
[/tex]

will give

\left( \begin{array}{cccc} 1 & 2 & 2 & 4\\ 5 & 6 & 7 & 8\end{array} \right)

We can also produce the following example:

Code:
[tex]
f(x) = 
\left\{
\bеgin{array}{rl}
-1 & x < 0\\
0 & x = 0\\
+1 & x > 0
\end{array}
\right.
[/tex]
This will give

f(x) = <br /> \left\{<br /> \begin{array}{rl}<br /> -1 &amp; x &lt; 0\\<br /> 0 &amp; x = 0\\<br /> +1 &amp; x &gt; 0<br /> \end{array}<br /> \right.<br />

Typing matrices can be significantly simplified using the pmatrix, bmatrix and vmatrix environments. See http://www.math-linux.com/spip.php?article132 for more information.

Sandbox:

If you wish to practice writing LATEX or test some code, a sandbox is available here: https://www.physicsforums.com/mathjax/test/preview.html
Please do not create threads in which to simply practice LATEX.
Additional information:

The Math & Science Software subforum, which often has active threads on LaTeX: https://www.physicsforums.com/forumdisplay.php?f=189

How to type multiple lines in a single LaTeX image: https://www.physicsforums.com/showthread.php?p=261329

You can get a drop-down menu of Latex while composing your post if you:

  • Are posting in one of the technical subforums
  • Are in Advanced Edit mode (click on "Go Advanced" to get there)
  • In Advanced Edit mode, click the icon

Simple non-LaTeX options:

Superscripts and subscripts can be entered using the and buttons while in Advanced Edit mode.

A quick-and-easy way to insert Greek letters and other math symbols in with normal text: https://www.physicsforums.com/blog.php?b=347 You just need to copy-and-paste the symbols.​

Acknowledgements

We are indebted to member and former admin chroot -- whose efforts brought LaTeX to Physics Forums in the first place -- and forum admin and owner Greg Bernhardt for updating to the currently-used MathJax processor. Numerous other members have provided valuable feedback and helped with the debugging process.​
 
Last edited by a moderator:


The above is my proposal. It's not much original, it's more of a reworking of redbelly's post and some other sources.

Question; I have refrained from typing [tеx] and [tеx] everywhere. Do you think this is ok, or should I type it nevertheless?
 


micromass said:
Important bug:
Physicsforums uses a LaTeX-software called mathjax. Mathjax has a quite important bug: after each 50 typed characters, it will automatically insert a space. This can screw up some LaTeX formula's. So be sure to insert a space regularly.

This is not a Mathjax bug - this is problem/feature of vBulletin. vBulletin divides long strings by inserting spaces, what Mathjax sees is already wrong.
 


Borek said:
This is not a Mathjax bug - this is problem/feature of vBulletin. vBulletin divides long strings by inserting spaces, what Mathjax sees is already wrong.

Thanks! I edited it.
 


The plural of formula is formulas. There's no apostrophe.

For matrices, most users will find it easier to use the pmatrix, bmatrix, and vmatrix environments. (There's another one, I think, but I can't remember the name.)
 


vela said:
The plural of formula is formulas. There's no apostrophe.

Fixed. Thanks!

For matrices, most users will find it easier to use the pmatrix, bmatrix, and vmatrix environments. (There's another one, I think, but I can't remember the name.)

I did not include these on purpose. I want to make it clear that people can choose their own delimiters. With things like bmatrix, they cannot. It is my opinion, that if people understand the array environment, then they can do much more than just with the bmatrix environment.

I could introduce bmatrix (and dertivatives) separately. But I want to keep the number of new commands as low as possible. Any thoughts??
 
  • #10


I think most users won't care about how to build a matrix out of \left, \right, and \array. They'd rather just know they can use pmatrix or one of its variants. I'd include both methods. Tell them about pmatrix and its variants, and then point out if they want more flexibility, for example, for an augmented matrix, they can use array. The piecewise function is also a good example of that, I think.

I discovered the ITEX and TEX tags aren't parsed when they're inside CODE tags, so you don't need to use the funny E's in there.
 
  • #11


fyi, MathJax 2.0 should be out soon and they are claiming some SVG support which could be interesting.
 
  • #12


micromass, Borek, Greg, You guys rock. One can get educated just by reading post here.
 
  • #13


Very nice!

I've never been a fan of the array environment, and I almost never use it. I use the pmatrix environment, the cases environment, and the align environments instead. I would explain those (check out the link to the page that explains "align" and my examples of "pmatrix" and "cases" in the post that Redbelly98 quoted), and perhaps leave out the array environment entirely. But I certainly don't mind if you also explain array as well. If you do, it should inlude a comment like this: The c stands for "centered". You can also use "l" for "left" and "r" for right."


\lambda^2 yields \lambda? Are you sure about that? :smile:

The part that mentions itex and tex tags, should use an example like this to illustrate the difference.

Code:
Let [itex]f:\mathbb R\rightarrow\mathbb R[/itex] be the function defined by [tex]f(x)=x^2,[/tex] for all [itex]x\in\mathbb R[/itex].
Let f:\mathbb R\rightarrow\mathbb R be the function defined by f(x)=x^2, for all x\in\mathbb R.

I would like to see a comment like this: If you're using tex tags and you want a comma or a period after your formula, you should put it before the closing tex tag. If you're using itex tags, it doesn't really matter if you put it before or after the closing itex tag.

Also: When you use tex tags, the software will put a blank line before and after the formula. So you don't have to type any line breaks before the opening tex tag or after the closing tex tag.

You typed "subscrpt" instead of subscript in one place.

I think the part about subscripts and superscripts should include an example like \Lambda^\mu{}_\nu, \Lambda^\mu{}_\nu, where the horizontal positioning of the indices matter.

You said that "\\ only works in some environments, such as array, align,,..." which is fine (except for the extra comma), but I don't think a newbie understands what an "environment" is. So you should say something like this: An environment is a piece of code that begins and ends with \begin and \end statements, for example
Code:
\begin{align}\end{align}


I like the list of common symbols that you linked to, but perhaps we should also explain a few of the most common codes ourselves:

The symbol for the real numbers. Code: \mathbb R. Result: \mathbb R. The \mathbb code works with other uppercase latin letters too (but not with lowercase letters or numbers).
Infinity. Code: \infty. Result: \infty
Planck's constant divided by 2\pi. Code: \hbar. Result: \hbar.
Complex conjugation. Code: z^* or \overline z. Result: z^*,\ \overline z.
The adjoint of a linear operator. Code: A^* or A^\dagger. Result: A^*,\ A^\dagger.
Accents. Code: \hat x, \vec x, \tilde x. Result \hat x,\ \vec x,\ \tilde x.
Partial derivatives. Code: \frac{\partial f}{\partial x}. Result: \frac{\partial f}{\partial x}.
Set theory notation. Code: \forall, \exists, \cup, \cap, \bigcup, \bigcap. Result: \forall,\ \exists,\ \cup,\ \cap,\ \bigcup,\ \bigcap
Dirac's bra-ket notation. Code: \langle\phi|\psi\rangle. Result: \langle\phi|\psi\rangle
Arrows. Code: \rightarrow, \Rightarrow, \Leftrightarrow. Result: \rightarrow,\ \Rightarrow,\ \Leftrightarrow.
Relations. Code: \geq, \leq, \approx. Result: \geq,\ \leq,\ \approx.

This would look nicer as a table. Comment: For all of these, you have to use curly brackets if you want the command to apply to more than one symbol, or to a symbol that has a code that includes a space, for example \overline{z+w}, \hat{\mathcal A}, \int_{-\infty}^\infty f(x)dx. \overline{z+w}, \hat{\mathcal A}., \int_{-\infty}^\infty f(x)dx.

I'm not sure I would even mention the \left. \right) trick, but I would explain how to choose the size of the delimiters manually. I rarely use \left and \right, because I feel that the result is often too big. So I use \bigg most of the time. I'd say something like this: If you want larger delimiters, then you can let LaTeX choose the sizes for you by using \left and \right, for example xe^x=x\left(\sum_{n=0}^\infty\frac{x^n}{n!}\right). xe^x=x\left(\sum_{n=0}^\infty\frac{x^n}{n!}\right) If you do, you must type a \left for each \right, and vice versa. Otherwise, the code will not work. You can also choose the sizes manually using the commands \big, \Big, \bigg, and \Bigg.

We should explain some MathJax features (zoom, view source, "scale all math...") or link to a page that does.

The quick edit bug should also be mentioned. If you edit a post that contains LaTeX code without going to "advanced mode" first, the code will not be parsed when you view the thread immediately after saving the changes. The math looks fine to everyone else, but you will need to refresh the page (in your browser) to see the math again.

The part about simple non-latex options should mention the fancy new box of symbols we have to the right of the box where you type your posts. (By the way, I think the × symbol is a major omission from that list. The · symbol would have been nice too, but × is used much more often, e.g. in the phrase "m×n matrix", or as a Cartesian product f:X×Y→ℝ).
 
Last edited:
  • #14


I agree with all your points Freferik. I'll make the necessary edits tomorrow. I'll delete the discusion on the array environment and the \left \right thingies.

I'll also make a small text that uses all these LaTeX commands in action. Showing the code and the result should be very benificial for the users.
 
  • #16


micromass said:
How do I work with LaTeX here?
Those fancy mathematical symbols are being made with something called LaTeX. Typing LaTeX-symbols in physicsforums is fairly easy. You just need to type the equations or symbols between [itеx] and [/itеx]. For example,
Code:
[itex] \lambda^2 [/itex]
will yield \lambda.

Alternatively, one can also type equations between [tеx] and [/tеx]. These tags do basically the same thing as itex, with the only example that they put everything on a separate line. So type
Code:
[tex] \lambda^2 [/tex]
yields \lambda^2​


I would change the second example to

Code:
[tex] \Lambda^2 [/tex]
yields \Lambda^2

Anyone with half a brain will see the generalization :wink:
 
  • #17


I don't want to discriminate against members who don't have half a brain. You could perhaps use something like \lambda\ \Lambda and \lambda\ \Lambda as your examples.

Maybe we should say something about spacing. We could mention that spaces and blank lines that you type won't show up in the image. If you're feeling ambitious, you could explain commands like

\ (followed by one or more spaces)
~
\,
\!
\quad
\qquad
\hspace{30mm}.

Hm, there must be some web page that explains those things, so we might as well find one and link to it instead.
 
  • #18


How do I work with LaTeX here?
Those fancy mathematical symbols are being made with something called LaTeX. Typing LaTeX-symbols in physicsforums is fairly easy. You just need to type the equations or symbols between [itеx] and [/itеx]. For example,
Code:
[itex] \lambda^2 [/itex]
will yield \lambda^2.

Alternatively, one can also type equations between [tеx] and [/tеx]. These tags do basically the same thing as itex, with the only example that they put everything on a separate line. So type
Code:
[tex] \Lambda^2 [/tex]
yields \Lambda^2

For the ones already familiar with LaTeX: the [itеx] brackets are analogous to $, and the [tеx] brackets are $$.

As another indication of the difference between [tеx] and [itеx], see the following example:

Code:
Let [itex]f:\mathbb R\rightarrow\mathbb R[/itex] be the function defined by [tex]f(x)=x^2,[/tex] for all [itex]x\in\mathbb R[/itex].

It yields:

Let f:\mathbb R\rightarrow\mathbb R be the function defined by f(x)=x^2, for all x\in\mathbb R.

Important note: If you're using tex tags and you want a comma or a period after your formula, you should put it before the closing tex tag. If you're using itex tags, it doesn't really matter if you put it before or after the closing itex tag.
Also, When you use tex tags, the software will put a blank line before and after the formula. So you don't have to type any line breaks before the opening tex tag or after the closing tex tag.

The easiest way to learn LaTeX is to see what others have done. If you see a post with a nice equation in it, just click QUOTE (at the bottom of the post) to see what the author did.

Important bug:
LaTeX in this forum has a quite important bug: after each 50 typed characters, it will automatically insert a space. This can screw up some LaTeX formulas. So be sure to insert a space regularly.

Another bug is that if you edit a post that contains LaTeX code without going to "advanced mode" first, the code will not be parsed when you view the thread immediately after saving the changes. The math looks fine to everyone else, but you will need to refresh the page (in your browser) to see the math again.
A very short introduction to LaTeX

So far, we know how to type in LaTeX, but we do not know the specific formulas. We will now introduce some of the more common formulas. A comprehensive list of formulas can be found at mirror.ctan.org/info/symbols/comprehensive/symbols-a4.pdf

Sadly, not all symbols are being supported by mathjax. To see a full list of suppoerted symbols, see http://www.mathjax.org/docs/1.1/tex.html

Now, we will introduce some easy formulas:

Special characters The following characters have a special meaning in LaTeX: # $ % { } _ ^ \ ~
The first six can be printed by \# \$ \% \{ \} \_

Lines and text \\ starts a new line, \ includes a space, \text{...} included text.

Note: \\ only works in some environments, such as array, align,... (an environment is a piece of code that begins with \bеgin and ends with \еnd statements, some important examples will follow later).

Spacing LaTeX does not care about space. For example

Code:
[tex]
x                                   y
[/tex]

will produce x y

To insert spaces, you need to use symbols like ~ or \. For example

Code:
[tex]
x \ \ \ \ \ \ \ \ \ \ y
[/tex]

gives x \ \ \ \ \ \ \ \ \ \ y

Subscripts and superscripts To type subscripts, just include _ For example
Code:
[itex]
x_y
[/itex]
will give x_y. For superscripts, use ^ For example,
Code:
[itex]
x^y
[/itex]
will give x^y

It might be necessary to include the brackets { }. For example,
Code:
[itex]
x^{x+y}
[/itex]
will give x^{x+y}. Typing
Code:
[itex]
x^x+y
[/itex]
will give x^x+y.

To produce examples like \Lambda^\mu{}_\nu, you have to use the following idea:

Code:
[itex]\Lambda^\mu{}_\nu[/itex]

Subscripts and superscripts work with integrals, limits, summations as well. For example,
Code:
[tex]
\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/tex]
will give us \lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}} If you do the same thing in itex, then you get \lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}. You notice that the subscript is written next to the limit instead of beneath it. To solve this, begin the text with \displaystyle. For example, typing
Code:
[itex]
\displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/itex]
will give \displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}

Delimiters The symbols ( ), [ ], \{ \} will give (~),[~], \{~\}.
If you want larger delimiters, then you have to use the \big, \Big, \bigg and \Bigg commands. For example

Code:
[tex]
xe^x = x \Big( \sum_{n=0}^\infty\frac{x^n}{n!} \Big)
[/tex]

will give xe^x = x \Big( \sum_{n=0}^\infty\frac{x^n}{n!} \Big) You can also let LaTeX choose the size of your delimiters. This can be done by typing \left and \right in front of the delimiter. For example

Code:
[tex]
xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right)
[/tex]

will give <br /> xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right)<br /> If you happen not to want a left or right delimiter, then you need to use \left. or \right. For example

Code:
[tex]
xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right.
[/tex]

will give <br /> xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right.<br />
Different fonts Sometimes we wish to type things in different font. For example the blackboard font \mathbb{N},\mathbb{Z},\mathbb{Q},\mathbb{R}, \mathbb{C} is typed by

Code:
[itex]
\mathbb{N},\mathbb{Z},\mathbb{Q},\mathbb{R},\mathbb{C}
[/itex]

Caligraphic fonts like \mathcal{T},\mathcal{U},\mathcal{B} are produced by

Code:
[itex]
\mathcal{T},\mathcal{U},\mathcal{B}
[/itex]

Note: these fonts only work with capital letters. Things like

Code:
[itex]
\mathcal{t}
[/itex]

will produce an error.

If you want to type something like f(x) \ \text{if} \ x&gt;0, then you have to type it like

Code:
[itex]
f(x) \ \text{if} \ x>0
[/itex]

Just typing

Code:
[itex]
f(x) if x>0
[/itex]

will give something ugly: f(x) if x&gt;0.
Frequently used symbols A nice list of frequently used symbols can be found at http://www.artofproblemsolving.com/Wiki/index.php/LaTeX:Symbols
Here we give a small sample of symbols you might want to use:

\begin{array}{|c|c|}<br /> \hline<br /> \text{\frac{1}{2}} &amp; \frac{1}{2}\\<br /> \hline<br /> \text{\sqrt{16}} &amp; \sqrt{16}\\<br /> \hline<br /> \text{\sqrt[4]{16}} &amp; \sqrt[4]{16}\\<br /> \hline<br /> \text{\infty} &amp; \infty\\<br /> \hline<br /> \text{\hbar} &amp; \hbar\\<br /> \hline<br /> \text{z^*, \bar{z}, z^\dagger} &amp; z^*, \bar{z}, z^\dagger\\<br /> \hline<br /> \text{\hat{z}, \vec{z}, \tilde{z}} &amp; \hat{z}, \vec{z}, \tilde{z}\\<br /> \hline<br /> \text{\frac{ \partial f }{ \partial x }} &amp; \frac{ \partial f }{ \partial x }\\<br /> \hline<br /> \text{\forall, \exists, \cup, \cap, \bigcup, \bigcap, \setminus, \in, \subseteq} &amp; \forall, \exists, \cup, \cap, \bigcup, \bigcap, \setminus, \in, \subseteq\\<br /> \hline<br /> \text{\langle \phi | \psi \rangle} &amp; \langle \phi | \psi \rangle\\<br /> \hline<br /> \text{\rightarrow, \leftarrow, \Rightarrow, \Leftrightarrow} &amp; \rightarrow, \leftarrow, \Rightarrow, \Leftrightarrow\\<br /> \hline<br /> \text{\geq, \leq, \approx, \cong, \sim} &amp; \geq, \leq, \approx, \cong, \sim\\<br /> \hline<br /> \text{ \binom{n}{k},{_nC_r}} &amp; \binom{n}{k},{_nC_r}\\<br /> \hline<br /> \text{\sin(x), \cos(x), \log(x)} &amp; \sin(x), \cos(x), \log(x)\\<br /> \hline<br /> \end{array}<br />
A comprehensive list of LaTeX commands can be found at www.stat.berkeley.edu/~sourav/symbols-a4.pdf[/URL]
The list of all supported MathJax commands can be found at [PLAIN]http://www.mathjax.org/docs/1.1/tex.html

Typing multiple equations Multiple equations can be typed be the align environment. Such an environment must be started with \bеgin{align} and ended with \еnd{align}. Rows must be separated by \\, an alignment is given by & (followed by a symbol). So for example

Code:
[tex]
\begin{align}
(1+x)^n &\geq 1+nx\\
&= \sqrt{(1+nx)^2}\\
&= \sqrt{1+2nx+n^2x^2}
\end{align}
[/tex]

This yields <br /> \begin{align}<br /> (1+x)^n &amp;\geq 1+nx\\<br /> &amp;= \sqrt{(1+nx)^2}\\<br /> &amp;= \sqrt{1+2nx+n^2x^2}<br /> \end{align}<br />
Typing matrices A matrix can easily by typed by the matrix, pmatrix, bmatrix and vmatrix environment. Such an environment must be started with \bеgin{pmatrix} and ended with \еnd{pmatrix}. Columns can be separated with & and ended with \\. Here is an example:

Code:
[tex]
\begin{pmatrix}
1 & 2 & 3 & 4\\
a & b & c & d\\
x & y & z & w
\end{pmatrix}
[/tex]

This yields <br /> \begin{pmatrix}<br /> 1 &amp; 2 &amp; 3 &amp; 4\\<br /> a &amp; b &amp; c &amp; d\\<br /> x &amp; y &amp; z &amp; w<br /> \end{pmatrix}<br />
The matrix, bmatrix and vmatrix environments produce the same results, but the delimiters are different. See http://www.math-linux.com/spip.php?article132 for more examples.

The cases environment Something like <br /> \begin{cases}<br /> 2x+y+z &amp; = 0\\<br /> 3x+4y+5z &amp; = 0\\<br /> x+2y+8z &amp; = 0<br /> \end{cases}<br /> Can be easily typed be the cases environment. Such an environment must be started with \bеgin{cases} and ended with \еnd{cases}. Rows must be separated with \\ and an invisible alignment is entered with &. The example above is produced by

Code:
[tex]
\begin{cases}
2x+y+z & = 0\\
3x+4y+5z & = 0\\
x+2y+8z & = 0
\end{cases}
[/tex]

Another example is

Code:
[tex]
u(x) =
\begin{cases}
\exp{x} & \text{if } x \geq 0 \\
1       & \text{if } x < 0
\end{cases}
[/tex]

which gives <br /> u(x) =<br /> \begin{cases}<br /> \exp{x} &amp; \text{if } x \geq 0 \\<br /> 1 &amp; \text{if } x &lt; 0<br /> \end{cases}<br /> More information about such an environment is found in http://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics
Sandbox:

If you wish to practice writing LATEX or test some code, a sandbox is available here: https://www.physicsforums.com/mathjax/test/preview.html
Please do not create threads in which to simply practice LATEX.
Additional information:

The Math & Science Software subforum, which often has active threads on LaTeX: https://www.physicsforums.com/forumdisplay.php?f=189

You can get a drop-down menu of Latex while composing your post if you:

  • Are posting in one of the technical subforums
  • Are in Advanced Edit mode (click on "Go Advanced" to get there)
  • In Advanced Edit mode, click the icon

MathJax (the processor that physicsforums uses to produce LaTeX) also has a few view options. If you right click on a LaTeX symbol, then a menu will pop up with handy features. Here's what you can do:

  • Show Source: this shows original LaTeX code. This is handy if you want to see how something is typed.
  • Settings: Allows you to zoom in in equation. So it allows you to see some LaTex symbols bigger. In order for zoom to work, you need to set your zoom trigger. If you set it to "hover" (for example), then you zoom in every time you place your mouse over the LaTeX code.
  • MathJax Help: Has some additional help features for users. Check it out.
Simple non-LaTeX options:

Superscripts and subscripts can be entered using the and buttons while in Advanced Edit mode.

There also is a box of symbols right to the right of the box where you type the posts. Just click on a symbol and it appears in the post without LaTeX being necessary.

A quick-and-easy way to insert Greek letters and other math symbols in with normal text: https://www.physicsforums.com/blog.php?b=347 You just need to copy-and-paste the symbols.​

Acknowledgements

We are indebted to member and former admin chroot -- whose efforts brought LaTeX to Physics Forums in the first place -- and forum admin and owner Greg Bernhardt for updating to the currently-used MathJax processor. Numerous other members have provided valuable feedback and helped with the debugging process.​
 
Last edited by a moderator:
  • #19


The above includes changes suggested by vela, Borek and Frederik. Comments welcome!
 
  • #20


Nice work. These are a few observations:

"auther" should be "author"

Too many blank lines. You're not following the recommendation about not typing blank lines before and after tex tags. :smile: For best results, type
Code:
Sentence that includes an equation [tex]E=mc^2[/tex] and then more text.
I think the result looks best without a single newline character in the sentence (unless they're between the tex tags).

Not sure code tags are necessary around stuff like \hbar. Actually, I'm thinking that these symbols and their codes should appear in some sort of table. It would make the post significantly shorter and easier to read. I'll try to figure out a good way to do it in the morning if no one else has done it by then.

I would delete the sentence that links to the old thread about how to type multiple lines. It's an old thread and most of the math there looks bad, if it works at all.

I think "There also is a box of symbols right of the..." should be "There is also a box of symbols to the right of the..."
 
  • #21
Looking good!

In the second paragraph, separate is misspelled, and in the third, analogous has a typo.

For limits, I prefer to use \to to make the arrow, primarily because I'm lazy and it's much shorter to type than \rightarrow.
Code:
[tex]\lim_{x \to 0} \frac{\sin x}{x} = 1[/tex]
\lim_{x \to 0} \frac{\sin x}{x} = 1
For conjugation, I think \bar looks better than \overline, which makes the bar too long: \bar z vs. \overline z.

In the delimiters section, I wouldn't say that you have to use \big, etc., but that you can use them. Mention \left and \right can be used to let LaTeX automatically choose the size.

Since probability and combinatorics questions come up a lot, you might want to include
Code:
[tex]\binom{n}{k}[/tex]
\binom{n}{k}and
Code:
[tex]{_nC_r}[/tex]
{_nC_r}
In the fonts section, mention using \text to avoid mistakes like f(x) = x if x&gt;0, which should be f(x) = x\text{ if }x&gt;0.

I'd also point out the use of \ in front of the name of standard functions. A lot of posters don't know to do this so you see things like sin x instead of \sin x.

Are there any other common mistakes people seem to make or common notation people want to use? I think those should be covered in the FAQ if possible.
 
  • #22


I have made all the changes. I think the table looks pretty :approve:

What do you guys think??
 
  • #23


Very nice. We're officially down to nitpicking minor details now.

It still says "If you want larger delimiters, then you have to use..." I agree with vela that it would be better to write "then you can use" rather than "then you have to use".

There are still a few unnecessary blank lines: After the \Lambda^2. After xy. After x y.

Also, there are some section titles have only one blank line before the section title, but two after it. Doesn't it look better with two before and one after? Look at the section titles: "A very short introduction to LaTeX", "Sandbox", and the other section titles after that.

The first two section titles and the last don't end with a colon, but the others do. Maybe we could be more consistent? Perhaps drop all those colons?

Very minor nitpick: "...the [itеx] brackets are analogous to $, and the [tеx] brackets are $$". I think the end of that should be "are analogous to $$", because otherwise it looks like tex is more similar to $$ than itex is to $.

Consider deleting the newline character in "...the closing itex tag.
Also, When you use tex tags..." An alternative is to type another one, to get a blank line between the paragraphs. Oh yeah, and the W should be lower case.

In the "important bug" section, I would rather not say that LaTeX in this forum has a bug. It's better than the original version, but it still (kind of) suggests that the bug is in MathJax. I would rather say this:

vBulletin (the forum software) has a feature that will sometimes break correct LaTeX code. If you type more than 50 characters without a space, vBulletin will insert one for you after the 50th character. This will break the code unless you're lucky enough to have the space end up before a LaTeX command rather than in the middle of it. To prevent this from happening, you will have to make sure that your code contains a space at least once every 50 characters. If you often write long pieces of LaTeX code, you may want to start to routinely type extra spaces that will be ignored by the LaTeX processor, for example before equality signs and LaTeX commands that aren't arguments of other LaTeX commands.

(I don't mind using the word "bug" in the section title, because even though both pieces of software are doing exactly what they're supposed to, there's still a problem when we combine them.)

\subseteq but no \subset? (I'm one of those who only uses the latter). Oh yeah, I remember that you don't like the \mapsto arrow, but I do. So how about including that with the other arrows? Nice table by the way. :smile:

Edit: The paragraph that starts with "The easiest way to learn LaTeX is to see what others have done." is good, but should perhaps be in a different place. In the opening paragraph perhaps, or right after the first simple examples.

I suggest one more line in the table: \vec x\cdot\vec y, f\circ g, X\times Y.
 
Last edited:
  • #24


A few more nitpicks:

\sin \cos \log in the table: add something like "and many other common math functions"

"It might be necessary to include the brackets { }"

I would prefer a this under its own heading, because it's essential to know about it. e.g.

Grouping:
By default, LaTeX operations only act on the next single 'token' (a single character, or something starting with a '\' ) in what you type. To make them act on a longer pieces of input, use curly brackets { }.

Examples: x^{10}+y^{10} giives x^{10}+y^{10}.
x^10+y^10 would produce x^10+y^10 .

Sometimes it's useful to attach something to an empty pair of brackets, {}. For example A^i_j and A_j^i both give A^i_j, but A^i{}_j gives A^i{}_j and A_j{}^i gives A_j{}^i.

You can nest brackets within brackets as deeply as you want, to build up a complicated expression. For example \sqrt{1 + \sqrt{1 + \sqrt{1 + x}}} gives
\sqrt{1 + \sqrt{1 + \sqrt{1 + x}}}
 
  • #25


How do I work with LaTeX here?
Those fancy mathematical symbols are being made with something called LaTeX. Typing LaTeX-symbols in physicsforums is fairly easy. You just need to type the equations or symbols between [itеx] and [/itеx]. For example,
Code:
[itex] \lambda^2 [/itex]
will yield \lambda^2.

Alternatively, one can also type equations between [tеx] and [/tеx]. These tags do basically the same thing as itex, with the only example that they put everything on a separate line. So type
Code:
[tex] \Lambda^2 [/tex]
yields \Lambda^2
For the ones already familiar with LaTeX: the [itеx] brackets are analogous to $, and the [tеx] brackets are analogous to $$.

The easiest way to learn LaTeX is to see what others have done. If you see a post with a nice equation in it, just click QUOTE (at the bottom of the post) to see what the author did.

As another indication of the difference between [tеx] and [itеx], see the following example:

Code:
Let [itex]f:\mathbb R\rightarrow\mathbb R[/itex] be the function defined by [tex]f(x)=x^2,[/tex] for all [itex]x\in\mathbb R[/itex].

It yields:

Let f:\mathbb R\rightarrow\mathbb R be the function defined by f(x)=x^2, for all x\in\mathbb R.

Important note If you're using tex tags and you want a comma or a period after your formula, you should put it before the closing tex tag. If you're using itex tags, it doesn't really matter if you put it before or after the closing itex tag. Also, when you use tex tags, the software will put a blank line before and after the formula. So you don't have to type any line breaks before the opening tex tag or after the closing tex tag.

Important bug
vBulletin (the forum software) has a feature that will sometimes break correct LaTeX code. If you type more than 50 characters without a space, vBulletin will insert one for you after the 50th character. This will break the code unless you're lucky enough to have the space end up before a LaTeX command rather than in the middle of it. To prevent this from happening, you will have to make sure that your code contains a space at least once every 50 characters. If you often write long pieces of LaTeX code, you may want to start to routinely type extra spaces that will be ignored by the LaTeX processor, for example before equality signs and LaTeX commands that aren't arguments of other LaTeX commands.

Another bug is that if you edit a post that contains LaTeX code without going to "advanced mode" first, the code will not be parsed when you view the thread immediately after saving the changes. The math looks fine to everyone else, but you will need to refresh the page (in your browser) to see the math again.​
A very short introduction to LaTeX
So far, we know how to type in LaTeX, but we do not know the specific formulas. We will now introduce some of the more common formulas. A comprehensive list of formulas can be found at mirror.ctan.org/info/symbols/comprehensive/symbols-a4.pdf

Sadly, not all symbols are being supported by mathjax. To see a full list of supported symbols, see http://www.mathjax.org/docs/1.1/tex.html

Now, we will introduce some easy formulas:

Special characters The following characters have a special meaning in LaTeX: # $ % { } _ ^ \ ~
The first six can be printed by \# \$ \% \{ \} \_

Lines and text \\ starts a new line, \ includes a space, \text{...} included text.

Note: \\ only works in some environments, such as array, align,... (an environment is a piece of code that begins with \bеgin and ends with \еnd statements, some important examples will follow later).

Spacing LaTeX does not care about space. For example

Code:
[tex]
x                                   y
[/tex]

will produce x y
To insert spaces, you need to use symbols like ~ or \. For example

Code:
[tex]
x \ \ \ \ \ \ \ \ \ \ y
[/tex]

gives x \ \ \ \ \ \ \ \ \ \ y
Subscripts and superscripts To type subscripts, just include _ For example
Code:
[itex]
x_y
[/itex]
will give x_y. For superscripts, use ^ For example,
Code:
[itex]
x^y
[/itex]
will give x^y

Subscripts and superscripts work with integrals, limits, summations as well. For example,
Code:
[tex]
\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/tex]
will give us \lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}} If you do the same thing in itex, then you get \lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}. You notice that the subscript is written next to the limit instead of beneath it. To solve this, begin the text with \displaystyle. For example, typing
Code:
[itex]
\displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/itex]
will give \displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}

Grouping By default, LaTeX operations only act on a single character in what you type. To make them act on longer pieces of input, use curly brackets { }. For example

Code:
[itex]
x^{10}+x^10
[/itex]

gives x^{10}+x^10.

Sometimes it's useful to attack something to an empty pair of brackets, {}. See for example the difference in the following:

Code:
[itex]
\Lambda_\mu^\nu, \Lambda^\nu_\mu, \Lambda_\mu{}^\nu, \Lambda^\nu{}_\mu
[/itex]

gives <br /> \Lambda_\mu^\nu, \Lambda^\nu_\mu, \Lambda_\mu{}^\nu, \Lambda^\nu{}_\mu<br />.

You can nest brackets within brackets as deeply as you want to build up a complicated experssion. For example

Code:
[itex]
\sqrt{1+\sqrt{1+\sqrt{1+x}}}
[/itex]

gives <br /> \sqrt{1+\sqrt{1+\sqrt{1+x}}}<br />.

Delimiters The symbols ( ), [ ], \{ \} will give (~),[~], \{~\}.
If you want larger delimiters, then you can use the \big, \Big, \bigg and \Bigg commands. For example

Code:
[tex]
xe^x = x \Big( \sum_{n=0}^\infty\frac{x^n}{n!} \Big)
[/tex]

will give xe^x = x \Big( \sum_{n=0}^\infty\frac{x^n}{n!} \Big) You can also let LaTeX choose the size of your delimiters. This can be done by typing \left and \right in front of the delimiter. For example

Code:
[tex]
xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right)
[/tex]

will give <br /> xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right)<br /> If you happen not to want a left or right delimiter, then you need to use \left. or \right. For example

Code:
[tex]
\left\{ \int_1^{12}{x^3dx} \right.
[/tex]

will give <br /> \left\{ \int_1^{12}{x^3dx} \right.<br />
Different fonts Sometimes we wish to type things in different font. For example the blackboard font \mathbb{N},\mathbb{Z},\mathbb{Q},\mathbb{R}, \mathbb{C} is typed by

Code:
[itex]
\mathbb{N},\mathbb{Z},\mathbb{Q},\mathbb{R},\mathbb{C}
[/itex]

Caligraphic fonts like \mathcal{T},\mathcal{U},\mathcal{B} are produced by

Code:
[itex]
\mathcal{T},\mathcal{U},\mathcal{B}
[/itex]

Note: these fonts only work with capital letters. Things like

Code:
[itex]
\mathcal{t}
[/itex]

will produce an error.

If you want to type something like f(x) \ \text{if} \ x&gt;0, then you have to type it like

Code:
[itex]
f(x) \ \text{if} \ x>0
[/itex]

Just typing

Code:
[itex]
f(x) if x>0
[/itex]

will give something ugly: f(x) if x&gt;0.

Frequently used symbols A nice list of frequently used symbols can be found at http://www.artofproblemsolving.com/Wiki/index.php/LaTeX:Symbols
Here we give a small sample of symbols you might want to use:

\begin{array}{|c|c|}<br /> \hline<br /> \text{\frac{1}{2}} &amp; \frac{1}{2}\\<br /> \hline<br /> \text{\sqrt{16}} &amp; \sqrt{16}\\<br /> \hline<br /> \text{\sqrt[4]{16}} &amp; \sqrt[4]{16}\\<br /> \hline<br /> \text{\infty} &amp; \infty\\<br /> \hline<br /> \text{\hbar} &amp; \hbar\\<br /> \hline<br /> \text{z^*, \bar{z}, z^\dagger} &amp; z^*, \bar{z}, z^\dagger\\<br /> \hline<br /> \text{\hat{z}, \vec{z}, \tilde{z}, \dot{z}, \ddot{z}} &amp; \hat{z}, \vec{z}, \tilde{z}, \dot{z}, \ddot{z}\\<br /> \hline<br /> \text{\frac{ \partial f }{ \partial x }} &amp; \frac{ \partial f }{ \partial x }\\<br /> \hline<br /> \text{\forall, \exists, \cup, \cap, \bigcup, \bigcap, \setminus, \in, \subseteq, \subset} &amp; \forall, \exists, \cup, \cap, \bigcup, \bigcap, \setminus, \in, \subseteq, \subset\\<br /> \hline<br /> \text{\langle \phi | \psi \rangle} &amp; \langle \phi | \psi \rangle\\<br /> \hline<br /> \text{\rightarrow, \leftarrow, \Rightarrow, \Leftrightarrow, \mapsto} &amp; \rightarrow, \leftarrow, \Rightarrow, \Leftrightarrow, \mapsto\\<br /> \hline<br /> \text{\geq, \leq, \approx, \cong, \sim} &amp; \geq, \leq, \approx, \cong, \sim\\<br /> \hline<br /> \text{\oplus, \otimes, \ne, \pm, \mp} &amp; \oplus, \otimes, \ne, \pm, \mp\\<br /> \hline<br /> \text{ \binom{n}{k},{_nC_r}} &amp; \binom{n}{k},{_nC_r}\\<br /> \hline<br /> \text{\sin(x), \cos(x), \log(x),...} &amp; \sin(x), \cos(x), \log(x),...\\<br /> \hline<br /> \text{A\cdot B, A\times B, f\circ g} &amp; A\cdot B, A\times B, f\circ g\\<br /> \hline<br /> \text{\int, \iint, \iiint, \oint} &amp; \int, \iint, \iiint, \oint\\<br /> \hline <br /> \text{\cdots, \vdots, \ddots, \dots} &amp; \cdots, \vdots, \ddots, \dots\\<br /> \hline<br /> \end{array}<br />
A comprehensive list of LaTeX commands can be found at www.stat.berkeley.edu/~sourav/symbols-a4.pdf[/URL]
The list of all supported MathJax commands can be found at [PLAIN]http://www.mathjax.org/docs/1.1/tex.html

Typing multiple equations Multiple equations can be typed be the align environment. Such an environment must be started with \bеgin{align} and ended with \еnd{align}. Rows must be separated by \\, an alignment is given by & (followed by a symbol). So for example

Code:
[tex]
\begin{align}
(1+x)^n &\geq 1+nx\\
&= \sqrt{(1+nx)^2}\\
&= \sqrt{1+2nx+n^2x^2}
\end{align}
[/tex]

This yields <br /> \begin{align}<br /> (1+x)^n &amp;\geq 1+nx\\<br /> &amp;= \sqrt{(1+nx)^2}\\<br /> &amp;= \sqrt{1+2nx+n^2x^2}<br /> \end{align}<br />
Typing matrices A matrix can easily by typed by the matrix, pmatrix, bmatrix and vmatrix environment. Such an environment must be started with \bеgin{pmatrix} and ended with \еnd{pmatrix}. Columns can be separated with & and ended with \\. Here is an example:

Code:
[tex]
\begin{pmatrix}
1 & 2 & 3 & 4\\
a & b & c & d\\
x & y & z & w
\end{pmatrix}
[/tex]

This yields <br /> \begin{pmatrix}<br /> 1 &amp; 2 &amp; 3 &amp; 4\\<br /> a &amp; b &amp; c &amp; d\\<br /> x &amp; y &amp; z &amp; w<br /> \end{pmatrix}<br />
The matrix, bmatrix and vmatrix environments produce the same results, but the delimiters are different. See http://www.math-linux.com/spip.php?article132 for more examples.

The cases environment Something like <br /> \begin{cases}<br /> 2x+y+z &amp; = 0\\<br /> 3x+4y+5z &amp; = 0\\<br /> x+2y+8z &amp; = 0<br /> \end{cases}<br /> Can be easily typed be the cases environment. Such an environment must be started with \bеgin{cases} and ended with \еnd{cases}. Rows must be separated with \\ and an invisible alignment is entered with &. The example above is produced by

Code:
[tex]
\begin{cases}
2x+y+z & = 0\\
3x+4y+5z & = 0\\
x+2y+8z & = 0
\end{cases}
[/tex]

Another example is

Code:
[tex]
u(x) =
\begin{cases}
\exp{x} & \text{if } x \geq 0 \\
1       & \text{if } x < 0
\end{cases}
[/tex]

which gives <br /> u(x) =<br /> \begin{cases}<br /> \exp{x} &amp; \text{if } x \geq 0 \\<br /> 1 &amp; \text{if } x &lt; 0<br /> \end{cases}<br /> More information about such an environment is found in http://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics
Sandbox
If you wish to practice writing LATEX or test some code, a sandbox is available here: https://www.physicsforums.com/mathjax/test/preview.html
Please do not create threads in which to simply practice LATEX.​
Additional information
The Math & Science Software subforum, which often has active threads on LaTeX: https://www.physicsforums.com/forumdisplay.php?f=189

You can get a drop-down menu of Latex while composing your post if you:

  • Are posting in one of the technical subforums
  • Are in Advanced Edit mode (click on "Go Advanced" to get there)
  • In Advanced Edit mode, click the icon

MathJax (the processor that physicsforums uses to produce LaTeX) also has a few view options. If you right click on a LaTeX symbol, then a menu will pop up with handy features. Here's what you can do:

  • Show Source: this shows original LaTeX code. This is handy if you want to see how something is typed.
  • Settings: Allows you to zoom in in equation. So it allows you to see some LaTex symbols bigger. In order for zoom to work, you need to set your zoom trigger. If you set it to "hover" (for example), then you zoom in every time you place your mouse over the LaTeX code.
  • MathJax Help: Has some additional help features for users. Check it out.
Simple non-LaTeX options
Superscripts and subscripts can be entered using the and buttons while in Advanced Edit mode.

There also is a box of symbols right to the right of the box where you type the posts. Just click on a symbol and it appears in the post without LaTeX being necessary.

A quick-and-easy way to insert Greek letters and other math symbols in with normal text: https://www.physicsforums.com/blog.php?b=347 You just need to copy-and-paste the symbols.​
Acknowledgements
We are indebted to member and former admin chroot -- whose efforts brought LaTeX to Physics Forums in the first place -- and forum admin and owner Greg Bernhardt for updating to the currently-used MathJax processor. Numerous other members have provided valuable feedback and helped with the debugging process.​
 
Last edited by a moderator:
  • #26


To the table, I suggest adding:

Integral symbols: \int, \iint, \iiint, \oint
Ellipses: \cdots, \vdots, \ddots, \dots
Dots: \dot{x}, \ddot{x}
Miscellaneous: \oplus, \otimes, \ne, \pm, \mp

Also, it might be worth having an example of a definite integral somewhere in the FAQ, perhaps in the delimiters section since you need big stuff in there anyway.
 
  • #27


vela said:
Also, it might be worth having an example of a definite integral somewhere in the FAQ

...and that would be a good place to mention that \, makes a small space, as in \int x\,dx = \int x\,dx
 
  • #28


Done.
 
  • #29


I think the FAQ is too long. I propose posting it in 3 posts:

- 1 post with everything except the introduction to LaTeX
- the introduction to LaTeX
- an example text.
 
  • #30


I thought of a few more suggestions for the table. Rather than inundate you with a stream of posts, I decided to try tweak the table on my own, and I got a bit carried away. This could be its own post, with links to and from the FAQ.

\begin{array}{l|c|c}
\hline
\text{Infinity} & \text{\infty} & \infty \\
\text{Reduced Planck's Constant} & \text{\hbar} & \hbar \\
\text{Plus-minus} & \text{\pm, \mp} & \pm, \mp \\
\text{Parallel} & \text{\parallel} & \parallel \\
\text{Perpendicular} & \text{\perp} & \perp \\
\text{For all} & \text{\forall} & \forall \\
\text{There exists} & \text{\exists} & \exists \\
\text{Ellipsis} & \text{\cdots, \vdots, \ddots, \dots} & \cdots, \vdots, \ddots, \dots \\
\hline
\text{Arrows} & \text{\rightarrow, \leftarrow} & \rightarrow, \leftarrow, \leftrightarrow \\
& \text{\Rightarrow, \Leftarrow, \Leftrightarrow} & \Rightarrow, \Leftarrow, \Leftrightarrow \\
& \text{\mapsto, \to} & \mapsto, \to \\
& \text{\uparrow, \downarrow} & \uparrow, \downarrow \\
\hline
\text{Relations} & \text{\geq, \leq, \neq} & \geq, \leq, \neq \\
& \text{\gg, \ll, \equiv} & \gg, \ll, \equiv \\
& \text{\approx, \cong, \sim} & \approx, \cong, \sim \\
\hline
\text{Superscript} & \text{x^n} & x^n \\
\text{Subscript} & \text{x_i} & x_i \\
\text{Tensor indices} & \text{R_{ab}{}^{cd}} & R_{ab}{}^{cd} \\
\text{Fraction} & \text{\frac{1}{2}} & \frac{1}{2} \\
\text{Square root} & \text{\sqrt{16}} & \sqrt{16} \\
\text{Nth root} & \text{\sqrt[4]{16}} & \sqrt[4]{16} \\
\text{Absolute value} & \text{|x|} & |x| \\
\text{Norm} & \text{\|\vec{x}\|} & \|\vec{x}\| \\
\text{Accents} & \text{\hat{p}, \vec{r}, \tilde{z}} & \hat{p}, \vec{r}, \tilde{z} \\
\text{Complex conjugate} & \text{z^*, \bar{z}, z^\dagger} & z^*, \bar{z}, z^\dagger \\
\text{Dirac notation} & \text{\langle \phi | \psi \rangle} & \langle \phi | \psi \rangle \\
\text{Multiplication} & \text{A \cdot B, A \times B} & A\cdot B, A\times B \\
\text{Direct Sum} & \text{V \oplus W} & V \oplus W \\
\text{Tensor Product} & \text{S \otimes T} & S \otimes T \\
\text{Function composition} & \text{f \circ g} & f\circ g \\
\text{Element of} & \text{x \in A} & x \in A \\
\text{Not in} & \text{x \not\in A} & x \not\in A \\
\text{Subset} & \text{A \subset B, B \subseteq C} & A \subset B, B \subseteq C \\
\text{Set Union} & \text{A \cup B} & A \cup B \\
\text{Set Intersection} & \text{A \cap B} & A \cap B \\
\text{Set Subtraction} & \text{A \setminus B} & A \setminus B \\
\hline
\text{Binomial coefficient} & \text{\binom{n}{k}, {_nC_r}} & \binom{n}{k}, {_nC_r} \\
\hline
\text{Big stuff} & \text{\bigcup_i A_i} & \bigcup_i A_i \\
& \text{\bigcap_i A_i} & \bigcap_i A_i \\
& \text{\sum_{n=0}^\infty a_n x^n} & \sum_{n=0}^\infty a_n x^n \\
& \text{\prod_{n=0}^\infty a_n} & \prod_{n=0}^\infty a_n \\
\hline
\text{Derivatives} & \text{y', y'', y^{(n)}} & y', y'', y^{(n)} \\
& \text{\dot{x}, \ddot{x}} & \dot{x}, \ddot{x} \\
& \text{\frac{\partial f}{\partial x}} & \frac{\partial f}{\partial x} \\
& \text{\nabla f} & \nabla f\\
& \text{\Box^2 \phi} & \Box^2 \phi \\
\hline
\text{Integrals} & \text{\int e^x\,dx} & \int e^x\,dx \\
& \text{\oint \vec{E}\cdot d\vec{A}} & \oint \vec{E}\cdot d\vec{A} \\
& \text{\iint, \iiint} & \iint, \iiint \\
\hline
\text{Elementary Functions} & \text{\sin x, \cos x, \log (x+y), ...} & \sin x, \cos x, \log(x+y), \dots \\
\hline
\end{array}
 
Last edited:
  • #31


"Sometimes it's useful to attack something..." Change attack to attach.

"The matrix, bmatrix and vmatrix environments produce the same results, but the delimiters are different". I think "the same" is too strong. I would change this to "The matrix, bmatrix and vmatrix environments produce similar results. Only the delimiters are different."

The bullet points under "You can get a drop-down menu of Latex while composing your post if you:" are a bit weird. I hope someone will correct me if what I'm saying is wrong, but I think that if each item is a different way to end the sentence you started before the list began, then there should be no colon after "if you", and each item should start with a lowercase character. The third one should probably say "are in Advanced Edit mode and click the Σ button." An alternative is to change the text before the list to a complete sentence, and then make each item in the list a complete sentence.

The first sentence under "Additional information". I would change it to this: If you have questions, you can ask them in the The Math & Science Software subforum.



I suggest that you replace the content of the "Simple non-LaTeX options" section with this:

If you just want a subscript or a superscript, you can use vBulletin's sub and sup tags. For example, [noparse]x1[/noparse] yields x1, and [noparse]x2[/noparse] yields x2. If you don't want to type these tags, you can use the X2 and X2 buttons above the input field when you're in Advanced Edit mode.

If you just want to insert a Greek letter or a mathematical symbol in your post, the easiest way is to just click on the symbol you want in the box of symbols to the right of the input field when you're in Advanced Edit mode. If you need a symbol that you don't see in that box, you can try to find it in https://www.physicsforums.com/blog.php?b=347 at the website of the Pennsylvania State University.

Do not use these symbols, the sub/sup tags, or any other vBulletin tags in LaTeX mode (i.e. between tex or itex tags).


I like vela's table. It should perhaps be in a separate post on the same page. In the main text, where your table is now, you can just mention that there's a table of common symbols and their LaTeX code in a separate post below. How about adding \uparrow and \downarrow? They are sometimes used when discussing spin-1/2 systems. \left|\uparrow\right\rangle
 
Last edited by a moderator:
  • #32


How do I work with LaTeX here?
Those fancy mathematical symbols are being made with something called LaTeX. Typing LaTeX-symbols in physicsforums is fairly easy. You just need to type the equations or symbols between [itеx] and [/itеx]. For example,
Code:
[itex] \lambda^2 [/itex]
will yield \lambda^2.

Alternatively, one can also type equations between [tеx] and [/tеx]. These tags do basically the same thing as itex, with the only example that they put everything on a separate line. So type
Code:
[tex] \Lambda^2 [/tex]
yields \Lambda^2
For the ones already familiar with LaTeX: the [itеx] brackets are analogous to $, and the [tеx] brackets are analogous to $$.

The easiest way to learn LaTeX is to see what others have done. If you see a post with a nice equation in it, just click QUOTE (at the bottom of the post) to see what the author did.

As another indication of the difference between [tеx] and [itеx], see the following example:

Code:
Let [itex]f:\mathbb R\rightarrow\mathbb R[/itex] be the function defined by [tex]f(x)=x^2,[/tex] for all [itex]x\in\mathbb R[/itex].

It yields:

Let f:\mathbb R\rightarrow\mathbb R be the function defined by f(x)=x^2, for all x\in\mathbb R.

Important note If you're using tex tags and you want a comma or a period after your formula, you should put it before the closing tex tag. If you're using itex tags, it doesn't really matter if you put it before or after the closing itex tag. Also, when you use tex tags, the software will put a blank line before and after the formula. So you don't have to type any line breaks before the opening tex tag or after the closing tex tag.

Important bug
vBulletin (the forum software) has a feature that will sometimes break correct LaTeX code. If you type more than 50 characters without a space, vBulletin will insert one for you after the 50th character. This will break the code unless you're lucky enough to have the space end up before a LaTeX command rather than in the middle of it. To prevent this from happening, you will have to make sure that your code contains a space at least once every 50 characters. If you often write long pieces of LaTeX code, you may want to start to routinely type extra spaces that will be ignored by the LaTeX processor, for example before equality signs and LaTeX commands that aren't arguments of other LaTeX commands.

Another bug is that if you edit a post that contains LaTeX code without going to "advanced mode" first, the code will not be parsed when you view the thread immediately after saving the changes. The math looks fine to everyone else, but you will need to refresh the page (in your browser) to see the math again.​
A very short introduction to LaTeX
So far, we know how to type in LaTeX, but we do not know the specific formulas. We will now introduce some of the more common formulas. A comprehensive list of formulas can be found at mirror.ctan.org/info/symbols/comprehensive/symbols-a4.pdf

Sadly, not all symbols are being supported by mathjax. To see a full list of supported symbols, see http://www.mathjax.org/docs/1.1/tex.html

Now, we will introduce some easy formulas:

Special characters The following characters have a special meaning in LaTeX: # $ % { } _ ^ \ ~
The first six can be printed by \# \$ \% \{ \} \_

Lines and text \\ starts a new line, \ includes a space, \text{...} included text.

Note: \\ only works in some environments, such as array, align,... (an environment is a piece of code that begins with \bеgin and ends with \еnd statements, some important examples will follow later).

Spacing LaTeX does not care about space. For example

Code:
[tex]
x                                   y
[/tex]

will produce x y
To insert spaces, you need to use symbols like ~ or \. For example

Code:
[tex]
x \ \ \ \ \ \ \ \ \ \ y
[/tex]

gives x \ \ \ \ \ \ \ \ \ \ y
Subscripts and superscripts To type subscripts, just include _ For example
Code:
[itex]
x_y
[/itex]
will give x_y. For superscripts, use ^ For example,
Code:
[itex]
x^y
[/itex]
will give x^y

Subscripts and superscripts work with integrals, limits, summations as well. For example,
Code:
[tex]
\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/tex]
will give us \lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}} If you do the same thing in itex, then you get \lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}. You notice that the subscript is written next to the limit instead of beneath it. To solve this, begin the text with \displaystyle. For example, typing
Code:
[itex]
\displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/itex]
will give \displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}

Grouping By default, LaTeX operations only act on a single character in what you type. To make them act on longer pieces of input, use curly brackets { }. For example

Code:
[itex]
x^{10}+x^10
[/itex]

gives x^{10}+x^10.

Sometimes it's useful to attach something to an empty pair of brackets, {}. See for example the difference in the following:

Code:
[itex]
\Lambda_\mu^\nu, \Lambda^\nu_\mu, \Lambda_\mu{}^\nu, \Lambda^\nu{}_\mu
[/itex]

gives <br /> \Lambda_\mu^\nu, \Lambda^\nu_\mu, \Lambda_\mu{}^\nu, \Lambda^\nu{}_\mu<br />.

You can nest brackets within brackets as deeply as you want to build up a complicated experssion. For example

Code:
[itex]
\sqrt{1+\sqrt{1+\sqrt{1+x}}}
[/itex]

gives <br /> \sqrt{1+\sqrt{1+\sqrt{1+x}}}<br />.

Delimiters The symbols ( ), [ ], \{ \} will give (~),[~], \{~\}.
If you want larger delimiters, then you can use the \big, \Big, \bigg and \Bigg commands. For example

Code:
[tex]
xe^x = x \Big( \sum_{n=0}^\infty\frac{x^n}{n!} \Big)
[/tex]

will give xe^x = x \Big( \sum_{n=0}^\infty\frac{x^n}{n!} \Big) You can also let LaTeX choose the size of your delimiters. This can be done by typing \left and \right in front of the delimiter. For example

Code:
[tex]
xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right)
[/tex]

will give <br /> xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right)<br /> If you happen not to want a left or right delimiter, then you need to use \left. or \right. For example

Code:
[tex]
\left\{ \int_1^{12}{x^3dx} \right.
[/tex]

will give <br /> \left\{ \int_1^{12}{x^3dx} \right.<br />
Different fonts Sometimes we wish to type things in different font. For example the blackboard font \mathbb{N},\mathbb{Z},\mathbb{Q},\mathbb{R}, \mathbb{C} is typed by

Code:
[itex]
\mathbb{N},\mathbb{Z},\mathbb{Q},\mathbb{R},\mathbb{C}
[/itex]

Caligraphic fonts like \mathcal{T},\mathcal{U},\mathcal{B} are produced by

Code:
[itex]
\mathcal{T},\mathcal{U},\mathcal{B}
[/itex]

Note: these fonts only work with capital letters. Things like

Code:
[itex]
\mathcal{t}
[/itex]

will produce an error.

If you want to type something like f(x) \ \text{if} \ x&gt;0, then you have to type it like

Code:
[itex]
f(x) \ \text{if} \ x>0
[/itex]

Just typing

Code:
[itex]
f(x) if x>0
[/itex]

will give something ugly: f(x) if x&gt;0.

Frequently used symbols A nice list of frequently used symbols can be found at http://www.artofproblemsolving.com/Wiki/index.php/LaTeX:Symbols
Here we give a small sample of symbols you might want to use:
<br /> \begin{array}{l|c|c}<br /> \hline<br /> \text{Infinity} &amp; \text{\infty} &amp; \infty \\<br /> \text{Reduced Planck&#039;s Constant} &amp; \text{\hbar} &amp; \hbar \\<br /> \text{Plus-minus} &amp; \text{\pm, \mp} &amp; \pm, \mp \\<br /> \text{Parallel} &amp; \text{\parallel} &amp; \parallel \\<br /> \text{Perpendicular} &amp; \text{\perp} &amp; \perp \\<br /> \text{For all} &amp; \text{\forall} &amp; \forall \\<br /> \text{There exists} &amp; \text{\exists} &amp; \exists \\<br /> \text{Ellipsis} &amp; \text{\cdots, \vdots, \ddots, \dots} &amp; \cdots, \vdots, \ddots, \dots \\<br /> \hline<br /> \text{Arrows} &amp; \text{\rightarrow, \leftarrow} &amp; \rightarrow, \leftarrow, \leftrightarrow \\<br /> &amp; \text{\Rightarrow, \Leftarrow, \Leftrightarrow} &amp; \Rightarrow, \Leftarrow, \Leftrightarrow \\<br /> &amp; \text{\mapsto, \to} &amp; \mapsto, \to \\<br /> &amp; \text{\uparrow, \downarrow} &amp; \uparrow, \downarrow \\<br /> \hline<br /> \text{Relations} &amp; \text{\geq, \leq, \neq} &amp; \geq, \leq, \neq \\<br /> &amp; \text{\gg, \ll, \equiv} &amp; \gg, \ll, \equiv \\<br /> &amp; \text{\approx, \cong, \sim} &amp; \approx, \cong, \sim \\<br /> \hline<br /> \text{Superscript} &amp; \text{x^n} &amp; x^n \\<br /> \text{Subscript} &amp; \text{x_i} &amp; x_i \\<br /> \text{Tensor indices} &amp; \text{R_{ab}{}^{cd}} &amp; R_{ab}{}^{cd} \\<br /> \text{Fraction} &amp; \text{\frac{1}{2}} &amp; \frac{1}{2} \\<br /> \text{Square root} &amp; \text{\sqrt{16}} &amp; \sqrt{16} \\<br /> \text{Nth root} &amp; \text{\sqrt[4]{16}} &amp; \sqrt[4]{16} \\<br /> \text{Absolute value} &amp; \text{|x|} &amp; |x| \\<br /> \text{Norm} &amp; \text{\|\vec{x}\|} &amp; \|\vec{x}\| \\<br /> \text{Accents} &amp; \text{\hat{p}, \vec{r}, \tilde{z}} &amp; \hat{p}, \vec{r}, \tilde{z} \\<br /> \text{Complex conjugate} &amp; \text{z^*, \bar{z}, z^\dagger} &amp; z^*, \bar{z}, z^\dagger \\<br /> \text{Dirac notation} &amp; \text{\langle \phi | \psi \rangle} &amp; \langle \phi | \psi \rangle \\<br /> \text{Multiplication} &amp; \text{A \cdot B, A \times B} &amp; A\cdot B, A\times B \\<br /> \text{Direct Sum} &amp; \text{V \oplus W} &amp; V \oplus W \\<br /> \text{Tensor Product} &amp; \text{S \otimes T} &amp; S \otimes T \\<br /> \text{Function composition} &amp; \text{f \circ g} &amp; f\circ g \\<br /> \text{Element of} &amp; \text{x \in A} &amp; x \in A \\<br /> \text{Not in} &amp; \text{x \not\in A} &amp; x \not\in A \\<br /> \text{Subset} &amp; \text{A \subset B, B \subseteq C} &amp; A \subset B, B \subseteq C \\<br /> \text{Set Union} &amp; \text{A \cup B} &amp; A \cup B \\<br /> \text{Set Intersection} &amp; \text{A \cap B} &amp; A \cap B \\<br /> \text{Set Subtraction} &amp; \text{A \setminus B} &amp; A \setminus B \\<br /> \hline<br /> \text{Binomial coefficient} &amp; \text{\binom{n}{k}, {_nC_r}} &amp; \binom{n}{k}, {_nC_r} \\<br /> \hline<br /> \text{Big stuff} &amp; \text{\bigcup_i A_i} &amp; \bigcup_i A_i \\<br /> &amp; \text{\bigcap_i A_i} &amp; \bigcap_i A_i \\<br /> &amp; \text{\sum_{n=0}^\infty a_n x^n} &amp; \sum_{n=0}^\infty a_n x^n \\<br /> &amp; \text{\prod_{n=0}^\infty a_n} &amp; \prod_{n=0}^\infty a_n \\<br /> \hline<br /> \text{Derivatives} &amp; \text{y&#039;, y&#039;&#039;, y^{(n)}} &amp; y&#039;, y&#039;&#039;, y^{(n)} \\<br /> &amp; \text{\dot{x}, \ddot{x}} &amp; \dot{x}, \ddot{x} \\<br /> &amp; \text{\frac{\partial f}{\partial x}} &amp; \frac{\partial f}{\partial x} \\<br /> &amp; \text{\nabla f} &amp; \nabla f\\<br /> &amp; \text{\Box^2 \phi} &amp; \Box^2 \phi \\<br /> \hline<br /> \text{Integrals} &amp; \text{\int e^x\,dx} &amp; \int e^x\,dx \\<br /> &amp; \text{\oint \vec{E}\cdot d\vec{A}} &amp; \oint \vec{E}\cdot d\vec{A} \\<br /> &amp; \text{\iint, \iiint} &amp; \iint, \iiint \\<br /> \hline<br /> \text{Elementary Functions} &amp; \text{\sin x, \cos x, \log (x+y), ...} &amp; \sin x, \cos x, \log(x+y), \dots \\<br /> \hline<br /> \end{array}<br />
A comprehensive list of LaTeX commands can be found at www.stat.berkeley.edu/~sourav/symbols-a4.pdf[/URL]
The list of all supported MathJax commands can be found at [PLAIN]http://www.mathjax.org/docs/1.1/tex.html

Typing multiple equations Multiple equations can be typed be the align environment. Such an environment must be started with \bеgin{align} and ended with \еnd{align}. Rows must be separated by \\, an alignment is given by & (followed by a symbol). So for example

Code:
[tex]
\begin{align}
(1+x)^n &\geq 1+nx\\
&= \sqrt{(1+nx)^2}\\
&= \sqrt{1+2nx+n^2x^2}
\end{align}
[/tex]

This yields <br /> \begin{align}<br /> (1+x)^n &amp;\geq 1+nx\\<br /> &amp;= \sqrt{(1+nx)^2}\\<br /> &amp;= \sqrt{1+2nx+n^2x^2}<br /> \end{align}<br />
Typing matrices A matrix can easily by typed by the matrix, pmatrix, bmatrix and vmatrix environment. Such an environment must be started with \bеgin{pmatrix} and ended with \еnd{pmatrix}. Columns can be separated with & and ended with \\. Here is an example:

Code:
[tex]
\begin{pmatrix}
1 & 2 & 3 & 4\\
a & b & c & d\\
x & y & z & w
\end{pmatrix}
[/tex]

This yields <br /> \begin{pmatrix}<br /> 1 &amp; 2 &amp; 3 &amp; 4\\<br /> a &amp; b &amp; c &amp; d\\<br /> x &amp; y &amp; z &amp; w<br /> \end{pmatrix}<br />
The matrix, bmatrix and vmatrix environments produce similar results. Only the delimiters are different. See http://www.math-linux.com/spip.php?article132 for more examples.

The cases environment Something like <br /> \begin{cases}<br /> 2x+y+z &amp; = 0\\<br /> 3x+4y+5z &amp; = 0\\<br /> x+2y+8z &amp; = 0<br /> \end{cases}<br /> Can be easily typed be the cases environment. Such an environment must be started with \bеgin{cases} and ended with \еnd{cases}. Rows must be separated with \\ and an invisible alignment is entered with &. The example above is produced by

Code:
[tex]
\begin{cases}
2x+y+z & = 0\\
3x+4y+5z & = 0\\
x+2y+8z & = 0
\end{cases}
[/tex]

Another example is

Code:
[tex]
u(x) =
\begin{cases}
\exp{x} & \text{if } x \geq 0 \\
1       & \text{if } x < 0
\end{cases}
[/tex]

which gives <br /> u(x) =<br /> \begin{cases}<br /> \exp{x} &amp; \text{if } x \geq 0 \\<br /> 1 &amp; \text{if } x &lt; 0<br /> \end{cases}<br /> More information about such an environment is found in http://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics
Sandbox
If you wish to practice writing LATEX or test some code, a sandbox is available here: https://www.physicsforums.com/mathjax/test/preview.html
Please do not create threads in which to simply practice LATEX.​
Additional information
If you have questions, you can ask them in The Math & Science Software subforum: https://www.physicsforums.com/forumdisplay.php?f=189

You can get a drop-down menu of Latex while composing your post if you

  • are posting in one of the technical subforums
  • are in Advanced Edit mode (click on "Go Advanced" to get there)
  • in Advanced Edit mode, click the Σ button.

MathJax (the processor that physicsforums uses to produce LaTeX) also has a few view options. If you right click on a LaTeX symbol, then a menu will pop up with handy features. Here's what you can do:

  • Show Source: this shows original LaTeX code. This is handy if you want to see how something is typed.
  • Settings: Allows you to zoom in in equation. So it allows you to see some LaTex symbols bigger. In order for zoom to work, you need to set your zoom trigger. If you set it to "hover" (for example), then you zoom in every time you place your mouse over the LaTeX code.
  • MathJax Help: Has some additional help features for users. Check it out.
Simple non-LaTeX options
If you just want a subscript or a superscript, you can use vBulletin's sub and sup tags. For example, x1 yields x1, and x2 yields x2. If you don't want to type these tags, you can use the X2 and X2 buttons above the input field when you're in Advanced Edit mode.

If you just want to insert a Greek letter or a mathematical symbol in your post, the easiest way is to just click on the symbol you want in the box of symbols to the right of the input field when you're in Advanced Edit mode. If you need a symbol that you don't see in that box, you can try to find it in https://www.physicsforums.com/blog.php?b=347 at the website of the Pennsylvania State University.

Do not use these symbols, the sub/sup tags, or any other vBulletin tags in LaTeX mode (i.e. between tex or itex tags).​
Acknowledgements
We are indebted to member and former admin chroot -- whose efforts brought LaTeX to Physics Forums in the first place -- and forum admin and owner Greg Bernhardt for updating to the currently-used MathJax processor. Numerous other members have provided valuable feedback and helped with the debugging process.​
 
Last edited by a moderator:
  • #33


Are there any more remarks?? I think this is very close to being postable.
 
  • #34


Sounds good. I haven't followed this discussion very closely, so at this point is it just Post #32 that is to be the FAQ entry?

If nobody objects then I'll go ahead and post it Wednesday afternoon, Eastern USA time. Feel free to remind me via PM if I don't get to it for some reason.
 
  • #36


Greg Bernhardt said:
Where are we putting it? Great job everyone!
O
I would prefer a special subforum in Forum feedback where we store all the FAQ's. Or perhaps a sticky post??
 
  • #37


micromass said:
O
I would prefer a special subforum in Forum feedback where we store all the FAQ's. Or perhaps a sticky post??

Let's sticky it and then we can unstick this one
https://www.physicsforums.com/showthread.php?t=386951
 
Last edited:
  • #38


If we simply un-stick the old sticky thread and leave it visible, I think we should add a warning right at the beginning that it's been superseded, with a link to the new FAQ.
 
  • #39


jtbell said:
If we simply un-stick the old sticky thread and leave it visible, I think we should add a warning right at the beginning that it's been superseded, with a link to the new FAQ.

good point, we can prolly delete it
 
  • #40


There are a few more details I would like to change, but right now I need to eat something. I'll edit my suggestions into this post about an hour from now.

I think we can definitely publish this today.
 
  • #41


Slightly OT - Greg, I know you were in contact with Mathjax developers, the table doesn't render correctly in Opera, see attachment.
 

Attachments

  • Untitled-1.png
    Untitled-1.png
    11.6 KB · Views: 73
  • #42


I realized that instead of explaining what I want to change, I can just quote the post, remove the quote tags and make the changes myself. Edit: I found several mistakes when I got out of the shower, including a paragraph that I had messed up by pasting a piece of text in the wrong place. I have fixed those mistakes now.

I think this is good enough to publish today.



How do I work with LaTeX here?
Those fancy mathematical symbols are being made with something called LaTeX. It's easy to include LaTeX code in your posts at Physics Forums. You just need to type the LaTeX code that produces the formula you want between [itеx] and [/itеx]. For example, if you type

Code:
[itex]\lambda^2[/itex]
the result will be \lambda^2.

Alternatively, you can type LaTeX code between [tеx] and [/tеx]. These tags do essentially the same thing as the itex tags, but the formula will be displayed indented on a separate line. So if you type

Code:
[tex]\Lambda^2[/tex]
the result will be \Lambda^2 For the ones already familiar with LaTeX: itex tags are analogous to $, and tex tags are analogous to $$.

The easiest way to learn LaTeX is to see what others have done. If you see a post with a nice equation in it, just click QUOTE (at the bottom of the post) to see what the author did.

Punctuation If you're using tex tags and you want a comma or a period after your formula, you should put it before the closing tex tag. If you're using itex tags, it doesn't matter if you put it before or after the closing itex tag. Also, when you use tex tags, the software will put a blank line before and after the formula. So you don't have to type any line breaks before the opening tex tag or after the closing tex tag. The following example illustrates these ideas.

Code:
Let [itex]f:\mathbb R\rightarrow\mathbb R[/itex] be the function defined by [tex]f(x)=x^2,[/tex] for all [itex]x\in\mathbb R[/itex].
Let f:\mathbb R\rightarrow\mathbb R be the function defined by f(x)=x^2, for all x\in\mathbb R.

Important bug vBulletin (the forum software) has a feature that will sometimes break correct LaTeX code. If you type more than 50 characters without a space, vBulletin will insert one for you after the 50th character. This will break the code unless you're lucky enough to have the space end up before a LaTeX command rather than in the middle of it. To prevent this from happening, you will have to make sure that your code contains a space at least once every 50 characters. If you often write long pieces of LaTeX code, you may want to start to routinely type extra spaces that will be ignored by the LaTeX processor, for example before equality signs and LaTeX commands that aren't arguments of other LaTeX commands.

Another bug is that if you edit a post that contains LaTeX code without going to advanced edit mode, the code will not be parsed when you view the thread immediately after saving the changes. The math looks fine to everyone else, but you will need to refresh the page (in your browser) to see the math again.​


A very short introduction to LaTeX
The previous section explains how to include LaTeX code in posts, but it doesn't explain LaTeX. So in this section, we will explain how to type common mathematical formulas in LaTeX.

Special characters The following characters have a special meaning in LaTeX: # $ % { } _ ^ \ ~
So if you want one of these characters to be displayed, you must type the code for the symbol rather than the symbol itself. The LaTeX codes for the first six of these symbols are: \# \$ \% \{ \} \_

Spacing LaTeX ignores most of the spaces and end-of-line characters you type. For example

Code:
[tex]
x     y
z
[/tex]
will produce x y<br /> z There is a number of LaTeX commands that you can use to control the horizontal distance between characters. \ or ~ (followed by a space) inserts a space. The difference is that ~ ensures that LaTeX will not break the line at that space. \, inserts a small space. \! inserts a small negative space (moves the cursor a little to the left). \quad and \qquad displays insert larger spaces. You can also use the \hspace command to explicitly specify the width of the space. For example,

Code:
[tex]
a\!b\,c\ d~e\quad f\qquad g\ \ \ \ h~~~~i\hspace{20mm}j
[/tex]
gives a\!b\,c\ d~e\quad f\qquad g\ \ \ \ h~~~~i\hspace{20mm}j To get the result f(x) \ \text{if} \ x&gt;0, you can't just type

Code:
[itex]
f(x) if x>0
[/itex]
The result will be ugly: f(x) if x&gt;0. Any of these codes will do a better job:

Code:
[itex]f(x)\ \text{if}\ x>0[/itex]
[itex]f(x)~\text{if}~x>0[/itex]
[itex]f(x)\text{ if }x>0[/itex]
These are the results: f(x)\ \text{if}\ x&gt;0, f(x)~\text{if}~x&gt;0, f(x)\text{ if }x&gt;0. The \text command tells LaTeX to interpret what comes next as text, instead of as variables.

Subscripts and superscripts To put a subscript on a variable, use the _ symbol. To put a superscript on a variable, use the ^ symbol. For example, if you type

Code:
[itex]
x_y,\ x^y
[/itex]
the result is x_y,\ x^y. If you want to display just the subscript or the superscript, and not the variable, type {} where the variable would normally be. This trick is also useful when the horizontal positioning of the indices is important, as in the following example.

Code:
[tex]
\Lambda^\mu_\nu,\ \Lambda_\nu^\mu,\ \Lambda^\mu{}_\nu,\ \Lambda_\nu{}^\mu
[/tex]
<br /> \Lambda^\mu_\nu,\ \Lambda_\nu^\mu,\ \Lambda^\mu{}_\nu,\ \Lambda_\nu{}^\mu<br /> Subscripts and superscripts work with integrals, limits, summations, and several other symbols. For example,
Code:
[tex]
\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/tex]
will give us \lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}} If you do the same thing between itex tags, then you get \lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}. The subscript is written next to the limit instead of beneath it. If you don't like this, you can use the \displaystyle command. For example,

Code:
[itex]
\displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/itex]
will give \displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}.

Grouping By default, most LaTeX commands act only on the first character or command on its right. (\displaystyle is one of the exceptions). To make them act on longer pieces of input, use curly brackets { }. For example

Code:
[itex]
x^{10}+x^10
[/itex]
gives x^{10}+x^10. If you want to limit the scope of a \displaystyle command, place the curly brackets as in this example

Code:
[itex]\lim_n x_n={\displaystyle\lim_n x_n}[/itex]
The result is \lim_n x_n={\displaystyle\lim_n x_n}.

You can nest brackets within brackets as deeply as you want to build up a complicated expression. For example

Code:
[itex]
\sqrt{1+\sqrt{1+\sqrt{1+x}}}
[/itex]

gives <br /> \sqrt{1+\sqrt{1+\sqrt{1+x}}}<br />.

Delimiters The delimiters (~),[~], \{~\} are typed as ( ), [ ], \{ \}. Note that a curly bracket must be preceded by a backslash. If you want larger delimiters, then you can use the \big, \Big, \bigg and \Bigg commands. For example

Code:
[tex]
xe^x = x \Big( \sum_{n=0}^\infty\frac{x^n}{n!} \Big)
[/tex]
will give xe^x = x \Big( \sum_{n=0}^\infty\frac{x^n}{n!} \Big) You can also let LaTeX choose the size of your delimiters. This can be done by typing \left and \right in front of the delimiter. For example

Code:
[tex]
xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right)
[/tex]
will give <br /> xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right)<br /> The size of the delimiters is determined by the size of what's between them. Because of this, there must be a \right for each \left and vice versa. So if you only want one of the delimiters to be displayed, you still have to tell LaTeX where the region that determines the size begins or ends, by typing "\left." or "\right." (i.e. you type a period instead of a delimiter), as in the following example.

Code:
[tex]
\left\{
\begin{array}{l}
x=r\cos\theta\\
y=r\sin\theta
\end{array}
\right.
~~\Rightarrow~~ x^2+y^2
=r^2(\underbrace{\cos^2\theta+\sin^2\theta}_{=1})=r^2
[/tex]
<br /> \left\{\begin{array}{l}<br /> x=r\cos\theta\\<br /> y=r\sin\theta<br /> \end{array}\right.<br /> ~~\Rightarrow~~ x^2+y^2<br /> =r^2(\underbrace{\cos^2\theta+\sin^2\theta}_{=1})=r^2<br /> The array environment is explained in one of the documents linked to after the table of common symbols below.

Different fonts Sometimes we wish to type things in a different font. For example Blackboard bold, Calligraphic, Fraktur or Sans serif. <br /> \begin{align}<br /> &amp;\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\<br /> &amp;\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\<br /> &amp;\mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\<br /> &amp;\mathsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}<br /> \end{align}<br /> The codes
Code:
[itex]\mathbb A[/itex]
[itex]\mathcal A[/itex]
[itex]\mathfrak A[/itex]
[itex]\mathsf A[/itex]
give the results \mathbb A, \mathcal A, \mathfrak A and \mathsf A respectively.

Note: The blackboard bold font only works with capital letters.


Frequently used symbols This is a list of some of the most useful symbols and their LaTeX codes:
<br /> \begin{array}{l|c|c}<br /> \hline<br /> \text{Infinity} &amp; \text{\infty} &amp; \infty \\<br /> \text{Reduced Planck&#039;s Constant} &amp; \text{\hbar} &amp; \hbar \\<br /> \text{Plus-minus} &amp; \text{\pm, \mp} &amp; \pm, \mp \\<br /> \text{Parallel} &amp; \text{\parallel} &amp; \parallel \\<br /> \text{Perpendicular} &amp; \text{\perp} &amp; \perp \\<br /> \text{For all} &amp; \text{\forall} &amp; \forall \\<br /> \text{There exists} &amp; \text{\exists} &amp; \exists \\<br /> \text{Ellipsis} &amp; \text{\cdots, \vdots, \ddots, \dots} &amp; \cdots, \vdots, \ddots, \dots \\<br /> \hline<br /> \text{Arrows} &amp; \text{\rightarrow, \leftarrow} &amp; \rightarrow, \leftarrow, \leftrightarrow \\<br /> &amp; \text{\Rightarrow, \Leftarrow, \Leftrightarrow} &amp; \Rightarrow, \Leftarrow, \Leftrightarrow \\<br /> &amp; \text{\mapsto, \to} &amp; \mapsto, \to \\<br /> &amp; \text{\uparrow, \downarrow} &amp; \uparrow, \downarrow \\<br /> \hline<br /> \text{Relations} &amp; \text{\geq, \leq, \neq} &amp; \geq, \leq, \neq \\<br /> &amp; \text{\gg, \ll, \equiv} &amp; \gg, \ll, \equiv \\<br /> &amp; \text{\approx, \cong, \sim} &amp; \approx, \cong, \sim \\<br /> \hline<br /> \text{Superscript} &amp; \text{x^n} &amp; x^n \\<br /> \text{Subscript} &amp; \text{x_i} &amp; x_i \\<br /> \text{Tensor indices} &amp; \text{R_{ab}{}^{cd}} &amp; R_{ab}{}^{cd} \\<br /> \text{Fraction} &amp; \text{\frac{1}{2}} &amp; \frac{1}{2} \\<br /> \text{Square root} &amp; \text{\sqrt{16}} &amp; \sqrt{16} \\<br /> \text{Nth root} &amp; \text{\sqrt[4]{16}} &amp; \sqrt[4]{16} \\<br /> \text{Absolute value} &amp; \text{|x|} &amp; |x| \\<br /> \text{Norm} &amp; \text{\|\vec{x}\|} &amp; \|\vec{x}\| \\<br /> \text{Accents} &amp; \text{\hat{p}, \vec{r}, \tilde{z}} &amp; \hat{p}, \vec{r}, \tilde{z} \\<br /> \text{Complex conjugate} &amp; \text{z^*, \bar{z}, z^\dagger} &amp; z^*, \bar{z}, z^\dagger \\<br /> \text{Dirac notation} &amp; \text{\langle \phi | \psi \rangle} &amp; \langle \phi | \psi \rangle \\<br /> \text{Multiplication} &amp; \text{A \cdot B, A \times B} &amp; A\cdot B, A\times B \\<br /> \text{Direct Sum} &amp; \text{V \oplus W} &amp; V \oplus W \\<br /> \text{Tensor Product} &amp; \text{S \otimes T} &amp; S \otimes T \\<br /> \text{Function composition} &amp; \text{f \circ g} &amp; f\circ g \\<br /> \text{Element of} &amp; \text{x \in A} &amp; x \in A \\<br /> \text{Not in} &amp; \text{x \not\in A} &amp; x \not\in A \\<br /> \text{Subset} &amp; \text{A \subset B, B \subseteq C} &amp; A \subset B, B \subseteq C \\<br /> \text{Set Union} &amp; \text{A \cup B} &amp; A \cup B \\<br /> \text{Set Intersection} &amp; \text{A \cap B} &amp; A \cap B \\<br /> \text{Set Subtraction} &amp; \text{A \setminus B} &amp; A \setminus B \\<br /> \hline<br /> \text{Binomial coefficient} &amp; \text{\binom{n}{k}, {_nC_r}} &amp; \binom{n}{k}, {_nC_r} \\<br /> \hline<br /> \text{Big stuff} &amp; \text{\bigcup_i A_i} &amp; \bigcup_i A_i \\<br /> &amp; \text{\bigcap_i A_i} &amp; \bigcap_i A_i \\<br /> &amp; \text{\sum_{n=0}^\infty a_n x^n} &amp; \sum_{n=0}^\infty a_n x^n \\<br /> &amp; \text{\prod_{n=0}^\infty a_n} &amp; \prod_{n=0}^\infty a_n \\<br /> \hline<br /> \text{Derivatives} &amp; \text{y&#039;, y&#039;&#039;, y^{(n)}} &amp; y&#039;, y&#039;&#039;, y^{(n)} \\<br /> &amp; \text{\dot{x}, \ddot{x}} &amp; \dot{x}, \ddot{x} \\<br /> &amp; \text{\frac{\partial f}{\partial x}} &amp; \frac{\partial f}{\partial x} \\<br /> &amp; \text{\nabla f} &amp; \nabla f\\<br /> &amp; \text{\Box^2 \phi} &amp; \Box^2 \phi \\<br /> \hline<br /> \text{Integrals} &amp; \text{\int e^x\,dx} &amp; \int e^x\,dx \\<br /> &amp; \text{\oint \vec{E}\cdot d\vec{A}} &amp; \oint \vec{E}\cdot d\vec{A} \\<br /> &amp; \text{\iint, \iiint} &amp; \iint, \iiint \\<br /> \hline<br /> \text{Elementary Functions} &amp; \text{\sin x, \cos x, \log (x+y), ...} &amp; \sin x, \cos x, \log(x+y), \dots \\<br /> \hline<br /> \end{array}<br />
Another nice list of frequently used symbols can be found http://www.artofproblemsolving.com/Wiki/index.php/LaTeX:Symbols (also a PDF file).

Sadly, not all LaTeX commands are being supported by MathJax. http://www.mathjax.org/docs/1.1/tex.html#supported-latex-commands is the full list of supported commands.

Formulas that span multiple lines Longer formulas and systems of equations can be typed using the align environment. An environment is a piece of code that begins with a \begin statement and ends with an \end statement. The align environment begins with \bеgin{align} and ends with \еnd{align}. Inside an align environment (and several other environments), the code \\ ends a line and starts a new one. The & symbol is used to indicate where rows are to be aligned, as in the following example.

Code:
[tex]
\begin{align}
(1+x)^n &\geq 1+nx\\
&= \sqrt{(1+nx)^2}\\
&= \sqrt{1+2nx+n^2x^2}
\end{align}
[/tex]

This yields <br /> \begin{align}<br /> (1+x)^n &amp;\geq 1+nx\\<br /> &amp;= \sqrt{(1+nx)^2}\\<br /> &amp;= \sqrt{1+2nx+n^2x^2}<br /> \end{align}<br />
Note: The \\ code only works in some environments.

Matrices A matrix can easily by typed by the matrix, pmatrix, bmatrix and vmatrix environment. For example, the pmatrix environment is started with \bеgin{pmatrix} and ended with \еnd{pmatrix}. Columns are separated by & and rows are separated by \\ . Here is an example:

Code:
[tex]
\begin{pmatrix}
1 & 2 & 3 & 4\\
a & b & c & d\\
x & y & z & w
\end{pmatrix}
[/tex]

This yields <br /> \begin{pmatrix}<br /> 1 &amp; 2 &amp; 3 &amp; 4\\<br /> a &amp; b &amp; c &amp; d\\<br /> x &amp; y &amp; z &amp; w<br /> \end{pmatrix}<br />
The matrix, bmatrix and vmatrix environments produce similar results. Only the delimiters are different. See http://www.math-linux.com/spip.php?article132 for more examples.

The cases environment Something like <br /> \begin{cases}<br /> 2x+y+z &amp; = 0\\<br /> 3x+4y+5z &amp; = 0\\<br /> x+2y+8z &amp; = 0<br /> \end{cases}<br /> can be easily typed using the cases environment. It is started with \bеgin{cases} and ended with \еnd{cases}. Rows must be separated by \\ and & is used to indicate where rows are to be aligned. The example above is produced by

Code:
[tex]
\begin{cases}
2x+y+z & = 0\\
3x+4y+5z & = 0\\
x+2y+8z & = 0
\end{cases}
[/tex]

Another example is

Code:
[tex]
u(x) =
\begin{cases}
\exp{x} & \text{if } x \geq 0 \\
1       & \text{if } x < 0
\end{cases}
[/tex]

which gives <br /> u(x) =<br /> \begin{cases}<br /> \exp{x} &amp; \text{if } x \geq 0 \\<br /> 1 &amp; \text{if } x &lt; 0<br /> \end{cases}<br /> More information about cases, align and similar environments can be found here.​


Sandbox
If you wish to practice writing LaTeX or test some code, a sandbox is available https://www.physicsforums.com/mathjax/test/preview.html . Please do not create threads just to practice LaTeX.​


Additional information
If you have questions, you can ask them in the Math & Science Software subforum.

If you go to advanced edit mode in one of the technical subforums (this doesn't work in the Forum Feedback & Announcements forum for example), you will see a button with a Σ symbol on it, above the input field. If you click on it, a menu with mathematical symbols will appear. When you select a symbol, its LaTeX code will be typed automatically, along with a pair of itex tags.

MathJax (the LaTeX processor) has a few setting that you can change. If you right-click on a LaTeX formula, then a menu will appear. Here's what you can do:

  • Show Source: this shows original LaTeX code. This is handy if you want to see how something is typed.
  • Settings: Allows you to zoom in in equation. So it allows you to see some LaTex symbols bigger. In order for zoom to work, you need to set your zoom trigger. If you set it to "hover" (for example), then you zoom in every time you place your mouse over the LaTeX code.
  • MathJax Help: Has some additional help features for users. Check it out.


Simple non-LaTeX options
If you just want a subscript or a superscript, you can use vBulletin's sub and sup tags. For example, [noparse]x1[/noparse] yields x1, and [noparse]x2[/noparse] yields x2. If you don't want to type these tags, you can use the X2 and X2 buttons above the input field when you're in advanced edit mode.

If you just want to insert a Greek letter or a mathematical symbol in your post, the easiest way is to just click on the symbol you want in the box of symbols to the right of the input field when you're in advanced edit mode. If you need a symbol that you don't see in that box, you can try to find it in https://www.physicsforums.com/blog.php?b=347 .

Do not use these symbols, the sub/sup tags, or any other vBulletin tags in LaTeX mode (i.e. between tex or itex tags).​


Acknowledgements
We are indebted to member and former admin chroot, whose efforts brought LaTeX to Physics Forums in the first place, and forum admin and owner Greg Bernhardt for updating to the currently-used MathJax processor. Numerous other members have provided valuable feedback and helped with the debugging process.​
 
Last edited by a moderator:
  • #43


In the punctuation section, how about breaking the code into two lines, so you don't have to scroll in the CODE box to see everything?

In the first example in the spacing section, y is missing in the code.

I'd add \mathrm to the fonts section, and perhaps give an example like 9.81~\mathrm{m/s}^2. A common mistake is to have the units typeset in the italic font.

In the cases section, right after the first typeset example, Can shouldn't be capitalized.

In the additional-information section, commas should be used instead of parentheses to set off the two phrases, and right click should be hyphenated.

In the acknowledgments, the dashes should be commas. If you really want dashes, use the endash (—) instead of two hyphens.

What do you think about removing the TEX and ITEX tags from all the CODE boxes other than in the How do I work with LaTeX? section? It'll make the FAQ look a bit shorter and, I think, cleaner. Or if we keep them, standardize on TEX.

I think the table should be moved to the end of the FAQ.
 
  • #44


vela said:
In the punctuation section, how about breaking the code into two lines, so you don't have to scroll in the CODE box to see everything?
I don't know, don't you think it looks kind of weird with a couple of line breaks inserted? The point of the example is to show how you should type a sentence that contains both tex and itex tags to get the best result, and you wouldn't type these line breaks.
Code:
Let [itex]f:\mathbb R\rightarrow
\mathbb R[/itex] be the function defined by [tex]f(x)
=x^2,[/tex] for all [itex]x\in\mathbb R[/itex].

vela said:
In the first example in the spacing section, y is missing in the code.
No, it was just 35 spaces to the right. I guess 5 spaces will illustrate the point just as well as 35, so I have deleted the rest of them.

vela said:
I'd add \mathrm to the fonts section, and perhaps give an example like 9.81~\mathrm{m/s}^2. A common mistake is to have the units typeset in the italic font.
I'm not familiar with the \mathrm command. A result of a google search suggests that it's like \text, but ignores spaces typed between the brackets and behaves slightly differently in other ways too. It doesn't seem to belong in the fonts section, but perhaps right after the place where I explained \text? If one of you guys would like to write a few sentences about it, I certainly wouldn't mind. Similar commands, like \operatorname and \mbox, should perhaps be mentioned too?


vela said:
In the cases section, right after the first typeset example, Can shouldn't be capitalized.

In the additional-information section, commas should be used instead of parentheses to set off the two phrases, and right click should be hyphenated.

In the acknowledgments, the dashes should be commas. If you really want dashes, use the endash (—) instead of two hyphens.
I had totally missed the "Can", and I just noticed that the sentence said "typed be the cases environment". I agree about the commas in the acknowledgments section.

I assume that you meant "are in Advanced Edit mode (click on "Go Advanced" to get there)"? Not sure I like a comma, since it's the part starting with "click" is a complete sentence. Maybe a semicolon? "are in Advanced Edit mode; click on "Go Advanced" to get there. Hm, you know what, I'll just rewrite that part. Check it out now.

Now that I think about it, do we even what to mention that feature? I wouldn't recommend it to anyone.

vela said:
What do you think about removing the TEX and ITEX tags from all the CODE boxes other than in the How do I work with LaTeX? section? It'll make the FAQ look a bit shorter and, I think, cleaner. Or if we keep them, standardize on TEX.
I thought about removing them earlier, but decided not to do it, at least not until we have discussed it. If we don't include them, we should probably change the sentences around them somewhat. For example, instead of "if you type <code>, the result is <result>", we would have to type something like "if you type <code> between tex tags, the result is <result>", or the statement wouldn't be 100% correct.

To standardize on tex would add more length to the post than we can remove by deleting the tags from the code boxes, so I vote against this, but I'm OK with it if you guys want to do it.


vela said:
I think the table should be moved to the end of the FAQ.
I don't know. Maybe. The point of the "a very short introduction to latex" section is to introduce the reader to the most useful latex codes, so it makes sense to keep it in that section. If you would like to move it, then it's OK with me, but one of you will have to do it. I'm done with this for today.
 
  • #45


Fredrik said:
I don't know, don't you think it looks kind of weird with a couple of line breaks inserted? The point of the example is to show how you should type a sentence that contains both tex and itex tags to get the best result, and you wouldn't type these line breaks.
I just meant one line break so you could see the whole thing in the box at once without needing to scroll horizontally:
Code:
Let [itex]f:\mathbb R\rightarrow \mathbb R[/itex] be the function defined
by [tex]f(x)=x^2,[/tex] for all [itex]x\in\mathbb R[/itex].
No, it was just 35 spaces to the right. I guess 5 spaces will illustrate the point just as well as 35, so I have deleted the rest of them.
Ah, guess I just didn't notice it way over there.
I'm not familiar with the \mathrm command. A result of a google search suggests that it's like \text, but ignores spaces typed between the brackets and behaves slightly differently in other ways too. It doesn't seem to belong in the fonts section, but perhaps right after the place where I explained \text? If one of you guys would like to write a few sentences about it, I certainly wouldn't mind. Similar commands, like \operatorname and \mbox, should perhaps be mentioned too.
It's just a different font, Roman. It's not like \text because you're still in math mode.

I assume that you meant "are in Advanced Edit mode (click on "Go Advanced" to get there)"?
I meant "(for example)" and "(the LaTeX processor)". If you're setting off a complete sentence, then yeah, parentheses or endashes would be appropriate.

I thought about removing them earlier, but decided not to do it, at least not until we have discussed it. If we don't include them, we should probably change the sentences around them somewhat. For example, instead of "if you type <code>, the result is <result>", we would have to type something like "if you type <code> between tex tags, the result is <result>", or the statement wouldn't be 100% correct.
I think people will understand, if they read the first section, that the LaTeX mark-up is understood to be sandwiched between the appropriate tags. To me, the tags seemed to be distracting by cluttering up and obscuring the actual LaTeX. But I can see the case for leaving them in there as well.
To standardize on tex would add more length to the post than we can remove by deleting the tags from the code boxes, so I vote against this, but I'm OK with it if you guys want to do it.
I did mean only in the CODE boxes if the tags were going to be left in. I don't see how that will add length to the post as it currently stands. If anything, it removes characters by replacing ITEX with TEX.
I don't know. Maybe. The point of the "a very short introduction to latex" section is to introduce the reader to the most useful latex codes, so it makes sense to keep it in that section. If you would like to move it, then it's OK with me, but one of you will have to do it. I'm done with this for today.
The table just seems to break the flow of the FAQ explaining the various features of LaTeX. It's not really an explanation; it's more like a reference guide. I'd move it to right before the sandbox section.
 
  • #46


vela said:
I just meant one line break so you could see the whole thing in the box at once without needing to scroll horizontally:
Code:
Let [itex]f:\mathbb R\rightarrow \mathbb R[/itex] be the function defined
by [tex]f(x)=x^2,[/tex] for all [itex]x\in\mathbb R[/itex].
If you put a line break there, it changes the output.

vela said:
I think people will understand, if they read the first section, that the LaTeX mark-up is understood to be sandwiched between the appropriate tags. To me, the tags seemed to be distracting by cluttering up and obscuring the actual LaTeX. But I can see the case for leaving them in there as well.
Yes, both possibilities are OK with me.

vela said:
I did mean only in the CODE boxes if the tags were going to be left in. I don't see how that will add length to the post as it currently stands. If anything, it removes characters by replacing ITEX with TEX.
You would use "tex" in the code box, even where we use "itex" to produce the output that we say is produced by what's in the code box? That would be misleading.

vela said:
The table just seems to break the flow of the FAQ explaining the various features of LaTeX. It's not really an explanation; it's more like a reference guide. I'd move it to right before the sandbox section.
If you can improve the flow, then go ahead. I'm going to watch some TV now and then go to bed early. If micromass shows up at night again, maybe you can discuss it with him (if you're still here). If you want to delay the publication until tomorrow so you can change a few things first, then make sure that Redbelly98 is aware of it, since he was going to publish it around...right now. (It's certainly OK with me).
 
  • #47


vela said:
What do you think about removing the TEX and ITEX tags from all the CODE boxes other than in the How do I work with LaTeX? section? It'll make the FAQ look a bit shorter and, I think, cleaner. Or if we keep them, standardize on TEX.

I think the TEX and ITEX tags in the code boxes add for clarity. People who are new and still confused about the matter see the code exactly how it should be typed. Moreover, people can just copy-paste the code if they want to test things.
Leaving the tags out is a little bit confusing for newcomers (although not much).

I think the table should be moved to the end of the FAQ.

I feel that the flow of the FAQ should go from important topics to unimportant topics. So the important stuff should be typed first, where most people will see it. I feel that the table is quite important and thus should be in the beginning of the FAQ.
 
  • #48


Fredrik said:
If you put a line break there, it changes the output.
Yes, you're right. I was thinking it would be inside the LaTeX so it wouldn't matter, but it's not. You could put the break right before the TEX tag instead, and it won't change the output.
Code:
Let [itex]f:\mathbb R\rightarrow\mathbb R[/itex] be the function defined by
[tex]f(x)=x^2,[/tex] for all [itex]x\in\mathbb R[/itex].
Let f:\mathbb R\rightarrow\mathbb R be the function defined by
f(x)=x^2, for all x\in\mathbb R.
micromass said:
I think the TEX and ITEX tags in the code boxes add for clarity. People who are new and still confused about the matter see the code exactly how it should be typed. Moreover, people can just copy-paste the code if they want to test things.
Leaving the tags out is a little bit confusing for newcomers (although not much).
Yeah, that was my other thought. Leaving them in is fine with me.
I feel that the flow of the FAQ should go from important topics to unimportant topics. So the important stuff should be typed first, where most people will see it. I feel that the table is quite important and thus should be in the beginning of the FAQ.
OK, sounds good.

I would still suggest you add \mathrm and perhaps \mathbf to the fonts section because bold Roman font is often used to denote vectors and matrices.
 
  • #49


How do I work with LaTeX here?
Those fancy mathematical symbols are being made with something called LaTeX. It's easy to include LaTeX code in your posts at Physics Forums. You just need to type the LaTeX code that produces the formula you want between [itеx] and [/itеx]. For example, if you type

Code:
[itex]\lambda^2[/itex]
the result will be \lambda^2.

Alternatively, you can type LaTeX code between [tеx] and [/tеx]. These tags do essentially the same thing as the itex tags, but the formula will be displayed indented on a separate line. So if you type

Code:
[tex]\Lambda^2[/tex]
the result will be \Lambda^2 For the ones already familiar with LaTeX: itex tags are analogous to $, and tex tags are analogous to $$.

The easiest way to learn LaTeX is to see what others have done. If you see a post with a nice equation in it, just click QUOTE (at the bottom of the post) to see what the author did.

Punctuation If you're using tex tags and you want a comma or a period after your formula, you should put it before the closing tex tag. If you're using itex tags, it doesn't matter if you put it before or after the closing itex tag. Also, when you use tex tags, the software will put a blank line before and after the formula. So you don't have to type any line breaks before the opening tex tag or after the closing tex tag. The following example illustrates these ideas.

Code:
Let [itex]f:\mathbb R\rightarrow\mathbb R[/itex] be the function defined by
[tex]f(x)=x^2,[/tex] for all [itex]x\in\mathbb R[/itex].
Let f:\mathbb R\rightarrow\mathbb R be the function defined by
f(x)=x^2, for all x\in\mathbb R.

Important bug vBulletin (the forum software) has a feature that will sometimes break correct LaTeX code. If you type more than 50 characters without a space, vBulletin will insert one for you after the 50th character. This will break the code unless you're lucky enough to have the space end up before a LaTeX command rather than in the middle of it. To prevent this from happening, you will have to make sure that your code contains a space at least once every 50 characters. If you often write long pieces of LaTeX code, you may want to start to routinely type extra spaces that will be ignored by the LaTeX processor, for example before equality signs and LaTeX commands that aren't arguments of other LaTeX commands.

Another bug is that if you edit a post that contains LaTeX code without going to advanced edit mode, the code will not be parsed when you view the thread immediately after saving the changes. The math looks fine to everyone else, but you will need to refresh the page (in your browser) to see the math again.​
A very short introduction to LaTeX
The previous section explains how to include LaTeX code in posts, but it doesn't explain LaTeX. So in this section, we will explain how to type common mathematical formulas in LaTeX.

Special characters The following characters have a special meaning in LaTeX: # $ % { } _ ^ \ ~
So if you want one of these characters to be displayed, you must type the code for the symbol rather than the symbol itself. The LaTeX codes for the first six of these symbols are: \# \$ \% \{ \} \_

Spacing LaTeX ignores most of the spaces and end-of-line characters you type. For example

Code:
[tex]
x     y
z
[/tex]
will produce x y<br /> z There is a number of LaTeX commands that you can use to control the horizontal distance between characters. \ or ~ (followed by a space) inserts a space. The difference is that ~ ensures that LaTeX will not break the line at that space. \, inserts a small space. \! inserts a small negative space (moves the cursor a little to the left). \quad and \qquad displays insert larger spaces. You can also use the \hspace command to explicitly specify the width of the space. For example,

Code:
[tex]
a\!b\,c\ d~e\quad f\qquad g\ \ \ \ h~~~~i\hspace{20mm}j
[/tex]
gives a\!b\,c\ d~e\quad f\qquad g\ \ \ \ h~~~~i\hspace{20mm}j To get the result f(x) \ \text{if} \ x&gt;0, you can't just type

Code:
[itex]
f(x) if x>0
[/itex]
The result will be ugly: f(x) if x&gt;0. Any of these codes will do a better job:

Code:
[itex]f(x)\ \text{if}\ x>0[/itex]
[itex]f(x)~\text{if}~x>0[/itex]
[itex]f(x)\text{ if }x>0[/itex]
These are the results: f(x)\ \text{if}\ x&gt;0, f(x)~\text{if}~x&gt;0, f(x)\text{ if }x&gt;0. The \text command tells LaTeX to interpret what comes next as text, instead of as variables.

Subscripts and superscripts To put a subscript on a variable, use the _ symbol. To put a superscript on a variable, use the ^ symbol. For example, if you type

Code:
[itex]
x_y,\ x^y
[/itex]
the result is x_y,\ x^y. If you want to display just the subscript or the superscript, and not the variable, type {} where the variable would normally be. This trick is also useful when the horizontal positioning of the indices is important, as in the following example.

Code:
[tex]
\Lambda^\mu_\nu,\ \Lambda_\nu^\mu,\ \Lambda^\mu{}_\nu,\ \Lambda_\nu{}^\mu
[/tex]
<br /> \Lambda^\mu_\nu,\ \Lambda_\nu^\mu,\ \Lambda^\mu{}_\nu,\ \Lambda_\nu{}^\mu<br /> Subscripts and superscripts work with integrals, limits, summations, and several other symbols. For example,
Code:
[tex]
\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/tex]
will give us \lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}} If you do the same thing between itex tags, then you get \lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}. The subscript is written next to the limit instead of beneath it. If you don't like this, you can use the \displaystyle command. For example,

Code:
[itex]
\displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}
[/itex]
will give \displaystyle\lim_{n\rightarrow +\infty} {\frac{\sin(x)}{x}}.

Grouping By default, most LaTeX commands act only on the first character or command on its right. (\displaystyle is one of the exceptions). To make them act on longer pieces of input, use curly brackets { }. For example

Code:
[itex]
x^{10}+x^10
[/itex]
gives x^{10}+x^10. If you want to limit the scope of a \displaystyle command, place the curly brackets as in this example

Code:
[itex]\lim_n x_n={\displaystyle\lim_n x_n}[/itex]
The result is \lim_n x_n={\displaystyle\lim_n x_n}.

You can nest brackets within brackets as deeply as you want to build up a complicated expression. For example

Code:
[itex]
\sqrt{1+\sqrt{1+\sqrt{1+x}}}
[/itex]

gives <br /> \sqrt{1+\sqrt{1+\sqrt{1+x}}}<br />.

Delimiters The delimiters (~),[~], \{~\} are typed as ( ), [ ], \{ \}. Note that a curly bracket must be preceded by a backslash. If you want larger delimiters, then you can use the \big, \Big, \bigg and \Bigg commands. For example

Code:
[tex]
xe^x = x \Big( \sum_{n=0}^\infty\frac{x^n}{n!} \Big)
[/tex]
will give xe^x = x \Big( \sum_{n=0}^\infty\frac{x^n}{n!} \Big) You can also let LaTeX choose the size of your delimiters. This can be done by typing \left and \right in front of the delimiter. For example

Code:
[tex]
xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right)
[/tex]
will give <br /> xe^x = x \left( \sum_{n=0}^\infty\frac{x^n}{n!} \right)<br /> The size of the delimiters is determined by the size of what's between them. Because of this, there must be a \right for each \left and vice versa. So if you only want one of the delimiters to be displayed, you still have to tell LaTeX where the region that determines the size begins or ends, by typing "\left." or "\right." (i.e. you type a period instead of a delimiter), as in the following example.

Code:
[tex]
\left\{
\begin{array}{l}
x=r\cos\theta\\
y=r\sin\theta
\end{array}
\right.
~~\Rightarrow~~ x^2+y^2
=r^2(\underbrace{\cos^2\theta+\sin^2\theta}_{=1})=r^2
[/tex]
<br /> \left\{\begin{array}{l}<br /> x=r\cos\theta\\<br /> y=r\sin\theta<br /> \end{array}\right.<br /> ~~\Rightarrow~~ x^2+y^2<br /> =r^2(\underbrace{\cos^2\theta+\sin^2\theta}_{=1})=r^2<br /> The array environment is explained in one of the documents linked to after the table of common symbols below.

Different fonts Sometimes we wish to type things in a different font. For example Blackboard bold, Calligraphic, Fraktur or Sans serif. <br /> \begin{align}<br /> &amp;\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\<br /> &amp;\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\<br /> &amp;\mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\<br /> &amp;\mathsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\<br /> &amp;\mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\<br /> &amp;\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}<br /> \end{align}<br /> The codes
Code:
[itex]\mathbb A[/itex]
[itex]\mathcal A[/itex]
[itex]\mathfrak A[/itex]
[itex]\mathsf A[/itex]
[itex]\mathrm A [/itex]
[itex]\mathbf A [/itex]
give the results \mathbb A, \mathcal A, \mathfrak A, \mathsf A, \mathrm A and \mathbf A respectively.

Note: The blackboard bold font only works with capital letters. Frequently used symbols This is a list of some of the most useful symbols and their LaTeX codes:
<br /> \begin{array}{l|c|c}<br /> \hline<br /> \text{Infinity} &amp; \text{\infty} &amp; \infty \\<br /> \text{Reduced Planck&#039;s Constant} &amp; \text{\hbar} &amp; \hbar \\<br /> \text{Plus-minus} &amp; \text{\pm, \mp} &amp; \pm, \mp \\<br /> \text{Parallel} &amp; \text{\parallel} &amp; \parallel \\<br /> \text{Perpendicular} &amp; \text{\perp} &amp; \perp \\<br /> \text{For all} &amp; \text{\forall} &amp; \forall \\<br /> \text{There exists} &amp; \text{\exists} &amp; \exists \\<br /> \text{Ellipsis} &amp; \text{\cdots, \vdots, \ddots, \dots} &amp; \cdots, \vdots, \ddots, \dots \\<br /> \hline<br /> \text{Arrows} &amp; \text{\rightarrow, \leftarrow} &amp; \rightarrow, \leftarrow, \leftrightarrow \\<br /> &amp; \text{\Rightarrow, \Leftarrow, \Leftrightarrow} &amp; \Rightarrow, \Leftarrow, \Leftrightarrow \\<br /> &amp; \text{\mapsto, \to} &amp; \mapsto, \to \\<br /> &amp; \text{\uparrow, \downarrow} &amp; \uparrow, \downarrow \\<br /> \hline<br /> \text{Relations} &amp; \text{\geq, \leq, \neq} &amp; \geq, \leq, \neq \\<br /> &amp; \text{\gg, \ll, \equiv} &amp; \gg, \ll, \equiv \\<br /> &amp; \text{\approx, \cong, \sim} &amp; \approx, \cong, \sim \\<br /> \hline<br /> \text{Superscript} &amp; \text{x^n} &amp; x^n \\<br /> \text{Subscript} &amp; \text{x_i} &amp; x_i \\<br /> \text{Tensor indices} &amp; \text{R_{ab}{}^{cd}} &amp; R_{ab}{}^{cd} \\<br /> \text{Fraction} &amp; \text{\frac{1}{2}} &amp; \frac{1}{2} \\<br /> \text{Square root} &amp; \text{\sqrt{16}} &amp; \sqrt{16} \\<br /> \text{Nth root} &amp; \text{\sqrt[4]{16}} &amp; \sqrt[4]{16} \\<br /> \text{Absolute value} &amp; \text{|x|} &amp; |x| \\<br /> \text{Norm} &amp; \text{\|\vec{x}\|} &amp; \|\vec{x}\| \\<br /> \text{Accents} &amp; \text{\hat{p}, \vec{r}, \tilde{z}} &amp; \hat{p}, \vec{r}, \tilde{z} \\<br /> \text{Complex conjugate} &amp; \text{z^*, \bar{z}, z^\dagger} &amp; z^*, \bar{z}, z^\dagger \\<br /> \text{Dirac notation} &amp; \text{\langle \phi | \psi \rangle} &amp; \langle \phi | \psi \rangle \\<br /> \text{Multiplication} &amp; \text{A \cdot B, A \times B} &amp; A\cdot B, A\times B \\<br /> \text{Direct Sum} &amp; \text{V \oplus W} &amp; V \oplus W \\<br /> \text{Tensor Product} &amp; \text{S \otimes T} &amp; S \otimes T \\<br /> \text{Function composition} &amp; \text{f \circ g} &amp; f\circ g \\<br /> \text{Element of} &amp; \text{x \in A} &amp; x \in A \\<br /> \text{Not in} &amp; \text{x \not\in A} &amp; x \not\in A \\<br /> \text{Subset} &amp; \text{A \subset B, B \subseteq C} &amp; A \subset B, B \subseteq C \\<br /> \text{Set Union} &amp; \text{A \cup B} &amp; A \cup B \\<br /> \text{Set Intersection} &amp; \text{A \cap B} &amp; A \cap B \\<br /> \text{Set Subtraction} &amp; \text{A \setminus B} &amp; A \setminus B \\<br /> \hline<br /> \text{Binomial coefficient} &amp; \text{\binom{n}{k}, {_nC_r}} &amp; \binom{n}{k}, {_nC_r} \\<br /> \hline<br /> \text{Big stuff} &amp; \text{\bigcup_i A_i} &amp; \bigcup_i A_i \\<br /> &amp; \text{\bigcap_i A_i} &amp; \bigcap_i A_i \\<br /> &amp; \text{\sum_{n=0}^\infty a_n x^n} &amp; \sum_{n=0}^\infty a_n x^n \\<br /> &amp; \text{\prod_{n=0}^\infty a_n} &amp; \prod_{n=0}^\infty a_n \\<br /> \hline<br /> \text{Derivatives} &amp; \text{y&#039;, y&#039;&#039;, y^{(n)}} &amp; y&#039;, y&#039;&#039;, y^{(n)} \\<br /> &amp; \text{\dot{x}, \ddot{x}} &amp; \dot{x}, \ddot{x} \\<br /> &amp; \text{\frac{\partial f}{\partial x}} &amp; \frac{\partial f}{\partial x} \\<br /> &amp; \text{\nabla f} &amp; \nabla f\\<br /> &amp; \text{\Box^2 \phi} &amp; \Box^2 \phi \\<br /> \hline<br /> \text{Integrals} &amp; \text{\int e^x\,dx} &amp; \int e^x\,dx \\<br /> &amp; \text{\oint \vec{E}\cdot d\vec{A}} &amp; \oint \vec{E}\cdot d\vec{A} \\<br /> &amp; \text{\iint, \iiint} &amp; \iint, \iiint \\<br /> \hline<br /> \text{Elementary Functions} &amp; \text{\sin x, \cos x, \log (x+y), ...} &amp; \sin x, \cos x, \log(x+y), \dots \\<br /> \hline<br /> \end{array}<br />
Another nice list of frequently used symbols can be found http://www.artofproblemsolving.com/Wiki/index.php/LaTeX:Symbols (also a PDF file).

Sadly, not all LaTeX commands are being supported by MathJax. http://www.mathjax.org/docs/1.1/tex.html#supported-latex-commands is the full list of supported commands.

Formulas that span multiple lines Longer formulas and systems of equations can be typed using the align environment. An environment is a piece of code that begins with a \begin statement and ends with an \end statement. The align environment begins with \bеgin{align} and ends with \еnd{align}. Inside an align environment (and several other environments), the code \\ ends a line and starts a new one. The & symbol is used to indicate where rows are to be aligned, as in the following example.

Code:
[tex]
\begin{align}
(1+x)^n &\geq 1+nx\\
&= \sqrt{(1+nx)^2}\\
&= \sqrt{1+2nx+n^2x^2}
\end{align}
[/tex]

This yields <br /> \begin{align}<br /> (1+x)^n &amp;\geq 1+nx\\<br /> &amp;= \sqrt{(1+nx)^2}\\<br /> &amp;= \sqrt{1+2nx+n^2x^2}<br /> \end{align}<br />
Note: The \\ code only works in some environments.

Matrices A matrix can easily by typed by the matrix, pmatrix, bmatrix and vmatrix environment. For example, the pmatrix environment is started with \bеgin{pmatrix} and ended with \еnd{pmatrix}. Columns are separated by & and rows are separated by \\ . Here is an example:

Code:
[tex]
\begin{pmatrix}
1 & 2 & 3 & 4\\
a & b & c & d\\
x & y & z & w
\end{pmatrix}
[/tex]

This yields <br /> \begin{pmatrix}<br /> 1 &amp; 2 &amp; 3 &amp; 4\\<br /> a &amp; b &amp; c &amp; d\\<br /> x &amp; y &amp; z &amp; w<br /> \end{pmatrix}<br />
The matrix, bmatrix and vmatrix environments produce similar results. Only the delimiters are different. See this web page for more examples.

The cases environment Something like <br /> \begin{cases}<br /> 2x+y+z &amp; = 0\\<br /> 3x+4y+5z &amp; = 0\\<br /> x+2y+8z &amp; = 0<br /> \end{cases}<br /> can be easily typed using the cases environment. It is started with \bеgin{cases} and ended with \еnd{cases}. Rows must be separated by \\ and & is used to indicate where rows are to be aligned. The example above is produced by

Code:
[tex]
\begin{cases}
2x+y+z & = 0\\
3x+4y+5z & = 0\\
x+2y+8z & = 0
\end{cases}
[/tex]

Another example is

Code:
[tex]
u(x) =
\begin{cases}
\exp{x} & \text{if } x \geq 0 \\
1       & \text{if } x < 0
\end{cases}
[/tex]

which gives <br /> u(x) =<br /> \begin{cases}<br /> \exp{x} &amp; \text{if } x \geq 0 \\<br /> 1 &amp; \text{if } x &lt; 0<br /> \end{cases}<br /> More information about cases, align and similar environments can be found here.​
Sandbox
If you wish to practice writing LaTeX or test some code, a sandbox is available https://www.physicsforums.com/mathjax/test/preview.html . Please do not create threads just to practice LaTeX.​
Additional information
If you have questions, you can ask them in the Math & Science Software subforum.

If you go to advanced edit mode in one of the technical subforums (this doesn't work in the Forum Feedback & Announcements forum for example), you will see a button with a Σ symbol on it, above the input field. If you click on it, a menu with mathematical symbols will appear. When you select a symbol, its LaTeX code will be typed automatically, along with a pair of itex tags.

MathJax (the LaTeX processor) has a few setting that you can change. If you right-click on a LaTeX formula, then a menu will appear. Here's what you can do:

  • Show Source: this shows original LaTeX code. This is handy if you want to see how something is typed.
  • Settings: Allows you to zoom in in equation. So it allows you to see some LaTex symbols bigger. In order for zoom to work, you need to set your zoom trigger. If you set it to "hover" (for example), then you zoom in every time you place your mouse over the LaTeX code.
  • MathJax Help: Has some additional help features for users. Check it out.
Simple non-LaTeX options
If you just want a subscript or a superscript, you can use vBulletin's sub and sup tags. For example, [noparse]x1[/noparse] yields x1, and [noparse]x2[/noparse] yields x2. If you don't want to type these tags, you can use the X2 and X2 buttons above the input field when you're in advanced edit mode.

If you just want to insert a Greek letter or a mathematical symbol in your post, the easiest way is to just click on the symbol you want in the box of symbols to the right of the input field when you're in advanced edit mode. If you need a symbol that you don't see in that box, you can try to find it in https://www.physicsforums.com/blog.php?b=347 .

Do not use these symbols, the sub/sup tags, or any other vBulletin tags in LaTeX mode (i.e. between tex or itex tags).​
Acknowledgements
We are indebted to member and former admin chroot, whose efforts brought LaTeX to Physics Forums in the first place, and forum admin and owner Greg Bernhardt for updating to the currently-used MathJax processor. Numerous other members have provided valuable feedback and helped with the debugging process.

The authors of this FAQ are
  • Fredrik
  • micromass
  • Redbelly98
  • vela
 
Last edited by a moderator:
  • #50


micromass said:
Acknowledgements
We are indebted to member and former admin chroot, whose efforts brought LaTeX to Physics Forums in the first place, and forum admin and owner Greg Bernhardt for updating to the currently-used MathJax processor. Numerous other members have provided valuable feedback and helped with the debugging process?​
Question mark at the end?
The authors of this FAQ are
  • Borek
  • Frederik
  • micromass
  • Redbelly98
  • vela
[/INDENT]
You misspelled Fredrik's name. :wink:
 

Similar threads

Replies
4
Views
4K
Replies
3
Views
2K
Replies
13
Views
554
Replies
1
Views
2K
Replies
1
Views
5K
Replies
766
Views
737K
Replies
11
Views
146K
Replies
0
Views
8K
Back
Top