Mastering LaTeX Equations: A Comprehensive Guide for Beginners on Physics Forums
Context: LaTeX
Thread starterRedbelly98
Start date
Click For Summary
Discussion Overview
The discussion revolves around improving resources and guidance for using LaTeX on Physics Forums, particularly for beginners. It covers the basics of posting equations and symbols, as well as more advanced topics like matrices and formatting issues.
Discussion Character
Exploratory
Technical explanation
Conceptual clarification
Debate/contested
Meta-discussion
Main Points Raised
Some participants suggest updating existing resources to provide clearer guidance for novices on how to post basic equations and symbols using LaTeX.
There is a proposal to include a comprehensive explanation of the differences between [itex] and [tex] tags, including examples of their usage.
Concerns are raised about outdated links and the need for cleanup in previous threads that contain irrelevant information and broken LaTeX code.
Participants mention specific bugs related to LaTeX input on the forum, such as the automatic insertion of spaces after 50 characters, which can disrupt formulas.
Some participants express the need for a more detailed and user-friendly guide that includes common formulas and symbols, as well as explanations of specific environments like align and array.
There is a discussion about the inadequacies of the current "how to LaTeX" document, including its failure to mention certain tags and formatting nuances.
Examples of LaTeX usage are provided, including how to create fractions, roots, and matrices, as well as the importance of using the correct syntax for subscripts and superscripts.
Areas of Agreement / Disagreement
Participants generally agree on the need for improved resources and clarity in LaTeX usage, but there are multiple competing views on how to best achieve this and what specific content should be included. The discussion remains unresolved regarding the best approach to updating the guides.
Contextual Notes
Limitations include the reliance on outdated threads and resources, as well as the presence of unresolved bugs that affect LaTeX functionality on the forum. There are also concerns about the clarity and accuracy of existing instructional materials.
Who May Find This Useful
Beginners looking to learn how to use LaTeX for posting equations on Physics Forums, as well as experienced users seeking to refine their understanding of LaTeX formatting and best practices.
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.)
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}).
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,
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
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 \\.
\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 & x < 0\\<br />
0 & x = 0\\<br />
+1 & x > 0<br />
\end{array}<br />
\right.<br />
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.
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.
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.
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.
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.)
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??
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.
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?
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→ℝ).
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.
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
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.
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,
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
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
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>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>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}} & \frac{1}{2}\\<br />
\hline<br />
\text{\sqrt{16}} & \sqrt{16}\\<br />
\hline<br />
\text{\sqrt[4]{16}} & \sqrt[4]{16}\\<br />
\hline<br />
\text{\infty} & \infty\\<br />
\hline<br />
\text{\hbar} & \hbar\\<br />
\hline<br />
\text{z^*, \bar{z}, z^\dagger} & z^*, \bar{z}, z^\dagger\\<br />
\hline<br />
\text{\hat{z}, \vec{z}, \tilde{z}} & \hat{z}, \vec{z}, \tilde{z}\\<br />
\hline<br />
\text{\frac{ \partial f }{ \partial x }} & \frac{ \partial f }{ \partial x }\\<br />
\hline<br />
\text{\forall, \exists, \cup, \cap, \bigcup, \bigcap, \setminus, \in, \subseteq} & \forall, \exists, \cup, \cap, \bigcup, \bigcap, \setminus, \in, \subseteq\\<br />
\hline<br />
\text{\langle \phi | \psi \rangle} & \langle \phi | \psi \rangle\\<br />
\hline<br />
\text{\rightarrow, \leftarrow, \Rightarrow, \Leftrightarrow} & \rightarrow, \leftarrow, \Rightarrow, \Leftrightarrow\\<br />
\hline<br />
\text{\geq, \leq, \approx, \cong, \sim} & \geq, \leq, \approx, \cong, \sim\\<br />
\hline<br />
\text{ \binom{n}{k},{_nC_r}} & \binom{n}{k},{_nC_r}\\<br />
\hline<br />
\text{\sin(x), \cos(x), \log(x)} & \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
This yields <br />
\begin{align}<br />
(1+x)^n &\geq 1+nx\\<br />
&= \sqrt{(1+nx)^2}\\<br />
&= \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 & 2 & 3 & 4\\<br />
a & b & c & d\\<br />
x & y & z & 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 & = 0\\<br />
3x+4y+5z & = 0\\<br />
x+2y+8z & = 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
which gives <br />
u(x) =<br />
\begin{cases}<br />
\exp{x} & \text{if } x \geq 0 \\<br />
1 & \text{if } x < 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.
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.
Too many blank lines. You're not following the recommendation about not typing blank lines before and after tex tags. 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..."
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>0, which should be f(x) = x\text{ if }x>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.
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.
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.
\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}}}
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,
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
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:
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
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>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>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}} & \frac{1}{2}\\<br />
\hline<br />
\text{\sqrt{16}} & \sqrt{16}\\<br />
\hline<br />
\text{\sqrt[4]{16}} & \sqrt[4]{16}\\<br />
\hline<br />
\text{\infty} & \infty\\<br />
\hline<br />
\text{\hbar} & \hbar\\<br />
\hline<br />
\text{z^*, \bar{z}, z^\dagger} & z^*, \bar{z}, z^\dagger\\<br />
\hline<br />
\text{\hat{z}, \vec{z}, \tilde{z}, \dot{z}, \ddot{z}} & \hat{z}, \vec{z}, \tilde{z}, \dot{z}, \ddot{z}\\<br />
\hline<br />
\text{\frac{ \partial f }{ \partial x }} & \frac{ \partial f }{ \partial x }\\<br />
\hline<br />
\text{\forall, \exists, \cup, \cap, \bigcup, \bigcap, \setminus, \in, \subseteq, \subset} & \forall, \exists, \cup, \cap, \bigcup, \bigcap, \setminus, \in, \subseteq, \subset\\<br />
\hline<br />
\text{\langle \phi | \psi \rangle} & \langle \phi | \psi \rangle\\<br />
\hline<br />
\text{\rightarrow, \leftarrow, \Rightarrow, \Leftrightarrow, \mapsto} & \rightarrow, \leftarrow, \Rightarrow, \Leftrightarrow, \mapsto\\<br />
\hline<br />
\text{\geq, \leq, \approx, \cong, \sim} & \geq, \leq, \approx, \cong, \sim\\<br />
\hline<br />
\text{\oplus, \otimes, \ne, \pm, \mp} & \oplus, \otimes, \ne, \pm, \mp\\<br />
\hline<br />
\text{ \binom{n}{k},{_nC_r}} & \binom{n}{k},{_nC_r}\\<br />
\hline<br />
\text{\sin(x), \cos(x), \log(x),...} & \sin(x), \cos(x), \log(x),...\\<br />
\hline<br />
\text{A\cdot B, A\times B, f\circ g} & A\cdot B, A\times B, f\circ g\\<br />
\hline<br />
\text{\int, \iint, \iiint, \oint} & \int, \iint, \iiint, \oint\\<br />
\hline <br />
\text{\cdots, \vdots, \ddots, \dots} & \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
This yields <br />
\begin{align}<br />
(1+x)^n &\geq 1+nx\\<br />
&= \sqrt{(1+nx)^2}\\<br />
&= \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 & 2 & 3 & 4\\<br />
a & b & c & d\\<br />
x & y & z & 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 & = 0\\<br />
3x+4y+5z & = 0\\<br />
x+2y+8z & = 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
which gives <br />
u(x) =<br />
\begin{cases}<br />
\exp{x} & \text{if } x \geq 0 \\<br />
1 & \text{if } x < 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.
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.
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.
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.