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.
  • #51


Fixed.
 
Physics news on Phys.org
  • #53


Micro, delete me from the list of authors - my picocontribution is not worth mentioning. Besides, people will start to think I know LaTeX, which is not true.
 
  • #54


vela said:
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.
Wow. I had no idea. This is really surprising to me. OK, then I don't mind inserting that extra line break, but if we do, I want insert an extra sentence that explains it. So I want to change
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.​
to
So you don't have to type any line breaks before the opening tex tag or after the closing tex tag. However, you can type a single line break before a tex tag without changing the output. The following example illustrates these ideas.​
And one final nitpick: The example I added that shows how to limit the scope of a \displaystyle has the itex tags on the same line as the latex code, while all of the other code boxes that contain a single code example have the tags on separate lines. So I would like to change this one to look like the others.

I think we can go ahead an publish this. (The mentor who posts it can make the minor changes I suggested above).
 
  • #55


I have one very small thing to add. I think the very first example should be a longer formula, such as

x^2 + y^2 + z^2 = \lambda^2

rather than simply \lambda^2. The reason is that the most common LaTeX error I see is that people try to use it for individual symbols, one at a time (and then often using sup/sub tags to attempt to position exponents and subscripts!). I can't imagine how many hours it must take them to compose posts this way, but it always makes the formulas completely unreadable, and frankly, I won't bother answering a question that isn't presented clearly.

I think the main cause is that people who are new to LaTeX simply do not realize that you can put an entire formula into a set of tex tags rather than just putting one symbol.

P.S. It drives me freaking nuts that the software puts an extra blank line after closing tex tags. I don't want to have to type everything all blocked together. It is easier to read the source code, and therefore easier to compose posts, if some extra line breaks are allowed.
 
  • #56


Ben Niehoff said:
The reason is that the most common LaTeX error I see is that people try to use it for individual symbols, one at a time (and then often using sup/sub tags to attempt to position exponents and subscripts!). I can't imagine how many hours it must take them to compose posts this way, but it always makes the formulas completely unreadable, and frankly, I won't bother answering a question that isn't presented clearly.

I think the main cause is that people who are new to LaTeX simply do not realize that you can put an entire formula into a set of tex tags rather than just putting one symbol.
I have seen that too. I don't think that these people are typing their LaTeX. They're probably using the LaTeX menu in advanced edit mode. (Not available in this forum, but open a thread in the Quantum Physics forum for example, and click "Go Advanced". Then click the Ʃ symbol above the input field).

Edit: Found another mistake. Please delete the word "displays" from "\quad and \qquad displays insert larger spaces" before publishing.

Another one: "has a few setting that" should be "has a few settings that"

Edit 2: I figured I might as well fix those mistakes. I followed Ben's suggestion and made the first examples of itex and tex more complicated, while making sure that the examples still use both \lambda and \Lambda. I also added the typewriter font, and the descriptions of the last few fonts. I changed the language a bit in the first paragraph after the table, and I changed "environment" to "environments" in one place.

I decided to change a detail in the description of the MathJax options, and ended up changing the whole thing.
 
Last edited:
  • #57


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]Ax=\lambda x[/itex]
the result will be Ax=\lambda x.

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^T\eta\Lambda=\eta.[/tex]
the result will be \Lambda^T\eta\Lambda=\eta. 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 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}=\lim_n x_n
[/itex]
The result is \lim_n x_n={\displaystyle\lim_n x_n}=\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, Sans serif, Roman (upright), bold and typewriter. <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 /> &amp;\mathtt{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]
[itex]\mathtt A[/itex]
give the results \mathbb A, \mathcal A, \mathfrak A, \mathsf A, \mathrm A, \mathbf A and \mathtt 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 environments. 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.

A left-click on a LaTeX image will by default display a box with a larger version of the same image. Try it on this one: x_{j_{2^k}} A right-click will display a menu where you can choose to
  • view the LaTeX source code.
  • change the factor by which the larger image is larger than the default size.
  • always scale all LaTeX images to a larger or smaller size.
  • change the zoom trigger, i.e. change what you have to do to make the larger image appear.
  • go to the MathJax help page.
If you change the zoom trigger to "hover", you will only have to hold the mouse pointer over the LaTeX image for the larger version to appear. However, this will also make it harder to right-click to bring up the menu, because a right-click on the larger image does nothing. So if you want to change it back, you have to be fast. Move the mouse pointer over the image, and right-click before the larger image appears.

Another way to see the LaTeX source code is of course to just click the QUOTE button next to the post. This is usually a better way, since it also shows the itex or tex tags, and the text around them, but it doesn't work in locked threads, or when the LaTeX image is in a quote box.​


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:
  • #58


Something in the post is setting the window size wider than usual (at least when I view it in Firefox). It looks fine until the Latex compiler renders the actual symbols, at which point the post jumps out to a wide stance.
 
  • #59


marcusl said:
Something in the post is setting the window size wider than usual (at least when I view it in Firefox). It looks fine until the Latex compiler renders the actual symbols, at which point the post jumps out to a wide stance.
That would have to be the table. However, I'm also using Firefox, and when I change the window size to one that's just large enough to get rid of the horizontal scrollbar, the window is a bit smaller than I usually keep it. It's too small to display the right edge of the box with greek letters and other symbols that you see in advanced edit mode.

Are you using some special feature, like "scale all math to 150%"?
 
  • #60


I have posted the new LaTeX as a stickied, locked thread in Forum Feedback:
https://www.physicsforums.com/showthread.php?t=546968

I had delayed doing this since there were still active discussions going on yesterday. I used Fredrik's post #57 with the following changes:

1. Changed the thread title and title for the opening "newbie" section.

2. Changed the two newbie example to be more at the high school level, instead of the examples from linear algebra in Post #57. The two examples I posted cover sub- and superscripts, upper- and lowercase Greek, and fractions. The Greek letters \theta \text{ and } \Delta are used, which are perhaps the most common ones encountered in U.S. high school math and science.

We can still make changes, like if we resolve the wide window issue that marcusl has brought up. If you spot any mistakes, keep posting them here. (And if a new FAQ subforum gets created, the post can be moved there.)
 
Last edited:
  • #61


Great. I like the thread title. Perhaps just "Getting started" would sound a little bit better than "Getting started for newbies"?

Small mistake: I wrote
\ or ~ (followed by a space) inserts a space​
but you don't have to type a space after ~. The codes are "\ " and "~". So for example
\ (followed by a space) or ~ inserts a space​
would be better.
 
  • #62


Good idea, Fredrik, I have made both changes.
 
  • #63


Found another mistake:
A matrix can easily by typed by the matrix, pmatrix, bmatrix and vmatrix environments.​
Should be something like
A matrix can easily be typed using the matrix, pmatrix, bmatrix or vmatrix environments.​

It looks like I somehow forgot to make the following change when I was doing some edits earlier:
Fredrik said:
I want to change
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.​
to
So you don't have to type any line breaks before the opening tex tag or after the closing tex tag. However, you can type a single line break before a tex tag without changing the output. The following example illustrates these ideas.​
I still want to make that change. But there's obviously no hurry.
 
  • #64


Fredrik said:
That would have to be the table. However, I'm also using Firefox, and when I change the window size to one that's just large enough to get rid of the horizontal scrollbar, the window is a bit smaller than I usually keep it. It's too small to display the right edge of the box with greek letters and other symbols that you see in advanced edit mode.

Are you using some special feature, like "scale all math to 150%"?
No; also, other threads looked fine.
Everything looks good now that I'm reading it on my computer at home, however.
Thanks for putting this together. It is well done and very useful!
 
  • #65


Fredrik said:
[Suggested a couple of changes]
Done.
marcusl said:
Thanks for putting this together. It is well done and very useful!
Agreed!
 
  • #66


Two more suggestions: We're talking about how to display something like "f(x) if x>0". I think it should say something like "f(x)=0 if x>0" instead. (Make sure to change it in all 8 places).

The sentence
This can be done by typing \left and \right in front of the delimiter.​
should be
This can be done by typing \left and \right in front of the delimiters.​
or
This can be done by typing \left or \right in front of the delimiter.​
Hm, my first thought was to choose the first option because it reinforces the idea that you need both a left and a right. However, from a language nazi's perspective, I think the second option is better, because the first one is actually saying that you should type stuff like \left\right(. This is of course harmless because of the example that clarifies what the sentence means. But the fact that the second option doesn't reinforce that you need both a left and a right is also harmless, since it's explicitly stated in the next paragraph.

I'll let you choose. :smile:
 
  • #67


Changes made. (I went with "...\left or \right...")
 
  • #68
There was an error in the table - \leftrightarrow was shown in the right column, but it was not present in the left column. Corrected.
 
  • #69
We should add something about simplified tags. Something like
Simplified tags: Instead of typing [itеx] and [/itеx], you can type #_# and #_#. Instead of typing [tеx] and [/tеx], you can type $_$ and $_$.​
but obviously without the _ characters. I don't see a way to type ## twice without everything between them getting interpreted as LaTeX code. Code tags would work of course, but it's kind of ugly. Anyone see a better way?
 
  • #70
This works (with the spaces deleted), but it makes IE8 run unbelievably slow, unless something else is causing that right now.

[ FONT = "Verdana" ] # # [ / FONT ]
 
Last edited:
  • #71
Oops, duplicate post, but there doesn't seem to be a "delete" button in this subforum.
 
  • #72
AlephZero said:
This works (with the spaces deleted), but it makes IE8 run unbelievably slow, unless something else is causing that right now.
Thanks. That works without any slowness in Firefox. Let me know if the slowness was just a temporary issue.
 
  • #73
FYI, new MathJax will be out soon. Here are the improvements:

New Features in MathJax v2.0:

• Major speed improvement for HTML-CSS output, particularly in IE:

The HTML-CSS output processing was redesigned to avoid the page reflows that were the main source of the speed problem in Internet Explorer 8 and 9. For test pages having between 20 and 50 expressions, we see an 80% reduction in output processing time for IE8, a 50% reduction for IE9, and between 15% and 25% reduction for most other browsers over the v1.1a times. Since the processing time in v1.1a grows non-linearly in IE, you should see even larger savings for pages with more equations when using v2.0. Forcing IE7 emulation mode is no longer necessary (and indeed is no longer recommended).

• Reduced flickering during typsetting:

In the past, each expression was displayed as soon as it was typeset, which caused a lot of visual flickering as MathJax processed the page. In v2.0, the output is processed in blocks so that typeset expressions are revealed in groups. This reduces the visual distraction, and also speeds up the processing. The number of equations in a block can be controlled through the EqnChunk parameter in the HTML-CSS block of your configuration. See config/default.js for details.

If the page URL includes a hash reference (a link to a particular location within the page), MathJax v2.0 will jump to that location after the page has finished typsetting. (Since the size of the page may have changed due to the mathematical typsetting, that location may no longer be visible on screen, so MathJax moves there when it is done with the initial typesetting.) You can control this behavior with the positionToHash parameter in the main section of your configuration.

• Automatic equation numbering of TeX formulas:

The TeX input jax now can be configured to add equation numbers (though the default is not to number equations so that existing pages will not change their appearance). This is controlled through the equationNumbers section of the TeX block of your configuration (see config/default.js for details). You can request that the numbering follow the AMS-style numbering of environments, or you can request that every displayed equation be numbered. There are now \label, \ref, and \eqref commands to make it easier to link to particular equations within the document.

• Automatic line breaking of long displayed equations:

MathJax now implements the MathML3 specification for automatic line breaking of displayed equations in its HTML-CSS output. This is disabled by default, but can be enabled via the linebreaks section of the HTML-CSS block of your configuration (see config/default.js for details).

• New AsciiMath input jax and SVG output jax:

MathJax currently processes math in either TeX/LaTeX format, or MathML notation; version 2.0 augments that to include ASCIIMathML notation (see http://www1.chapman.edu/~jipsen/mathml/asciimath.html for details on this format). This is a notation that is easier for students to use than TeX, and has been requested by the user community.

In addition to the HTML-CSS and Native MathML output available in v1.1, MathJax v2.0 includes an SVG-based output jax. This should prove to be more reliable than the HTML-CSS output, as it avoids some CSS, web-font, and printing issues that the HTML-CSS output suffers from, and it currently has no browser-dependent code. The SVG mode even works in some ebook readers (like Apple iBooks and Calibre).

• New combined configuration files:

Pre-defined configuration files that include the AsciiMath and SVG processors are now available with MathJax v2.0.

• MathJax contextual menu now available on mobile devices:

MathJax v2.0 provides access to its contextual menu in mobile devices that are based on the WebKit (Safari) and Gecko (Firefox) engines. For Mobile Firefox, the menu is accessed by a tap-and-hold on any expression rendered by MathJax (this is Mobile Firefox's standard method of triggering a contextual menu). In Mobile Safari, use a double-tap-and-hold. This is the first step toward providing a better interface for mobile devices.

• Improved support for screen readers:

Some issues surrounding the use of screen readers and their interaction with MathPlayer have been resolved in MathJax v2.0. In particular, there are additional menu items that allow the user finer control over some aspects of MathJax's interface that were interfering with some screen readers' ability to properly identify the mathematics. Several stability issues with MathPlayer have also been addressed.

• Many new TeX additions and enhancements:

• New mhchem chemistry extension (adds \ce, \cf, and \cee macros)
• New cancel extension (adds \cancel, \bcancel, and \cancelto macros)
• New extpfeil extension (adds more stretchy arrows)
• New color extension (makes \color work as a switch, as in LaTeX). Adds \definecolor, other color models, LaTeX named colors, \colorbox, \fcolorbox, etc.
• New begingroup extension to allow macro definitions to be localized. Adds \begingroup, \endgroup, \let, \renewenvironment, \global, and \gdef.
• New enclose extension to give TeX access to <menclose> elements. Adds \enclose{type}[attributes]{math} macro.
• New action extension to give TeX access to <maction> elements. Adds \mathtip{math}{tip}, \texttip{math}{tip}, and \toggle{math1}{math2}...\endtoggle macros.
• New \mmToken{type}[attributes]{text} macro for producing <mo>, <mi>, <mtext>, and other token MathML elements.
• New \bbox[color;attributes]{math} macro to add background color, padding, borders, etc.
• New \middle macro for stretchy delimiters between \left and \right.
• New \label, \ref, and \eqref macros for numbered equations.
• Better implementation of \not so it produces proper MathML when possible.
• Better implementation of \dots that selects \ldots or \cdots depending on the context.
• Better implementation of \cases that automatically uses \text on the second entry in each row.
• Safer implementation of \require that only allows loading from extensions directory.
• Allow \newcomand to provide a default parameter.
• Allow \\ to take an optional argument that specifies additional space between lines.
• Allow \\ to be used anywhere (to force a line break), not just in arrays.
• Allow optional alignment parameter for array, aligned, and gathered environments.

• Font enhancements:

• Work around for the OS X Lion STIX font problem.
• Support for STIX-1.1-beta fonts (detection of which version you have, and use data appropriate for that).
• New WOFF versions of the web fonts (smaller, so faster to download).
• Data for more stretchy characters in HTML-CSS output.
• Add support for Unicode planes 1 through 10 (not just the Math Alphabet block) in HTML-CSS output.
• Increased timeout for web fonts (since it was switching to image fonts too often, especially for mobile devices).
• Only switch to image fonts if the first web font fails to load (if we can access one, assume we can access them all).
• Allow <mtext> elements to use the page font rather than MathJax fonts (optionally).
• Provide better control over font used for characters that are not in the MathJax fonts.

• Interface improvements:

• The MathJax contextual menu has been reorganized to make it easier to get the source view, and to control the parameters for MathPlayer in IE.
• The MathJax contextual menu is available in mobile devices (see description above).
• Warning messages are issued if you switch renderers to one that is inappropriate for your browser.
• MathJax now starts processing the page on the DOMContentLoaded event rather than the onload event (this allows the mathematics to appear sooner).
• Native MathML output is now scaled to better match the surrounding font.
• Better CSS styling for NativeMML output in Firefox in order to handle \cal and other fonts.
• MathML output now (optionally) includes class names to help mark special situations generated by the TeX input jax. (This let's the MathML from the Show Source menu item better reproduce the original TeX output.)


• Important changes from previous versions:

• The default renderer for Firefox has been changed from NativeMML to HTML-CSS (in those configurations that choose between the two). The only browser that defaults to NativeMML is now IE with MathPlayer installed.

• NativeMML will now be selected in IE9 when MathPlayer is present (since IE9 was released the same day as MathJax v1.1a, and there had been problems with IE9 beta releases, we weren't sure if MathPlayer would work with the official release, and so did not select NativeMML by default.)

• The tex2jax preprocessor now balances braces when looking for the closing math delimiter. That allows expressions like $y = x^2 \hbox{ when $x > 2$}$ to be properly parsed as a single math expression rather than two separate ones with unbalanced braces. The old behavior can be obtained by setting balanceBraces to false in the tex2jax block of your configuration.

• A one pixel padding has been added above and below HTML-CSS output so that math on successive lines of a paragraph won't bump into each other.

• There is a new MathPlayer submenu of the Math Settings menu in the MathJax contextual menu that allows the user to control what events are passed on to MathPlayer. This allows better control for those using assistive devices like screen readers. When menu events are being passed on to MathPlayer, the MathJax menu can be obtained by ALT-clicking on a typeset expression (so the user can still access MathJax's other features).
 
  • #74
Is it ok for everybody if I add this text:

Simplified tags: Instead of typing [itеx] and [/itеx], you can type ## and ##. Instead of typing [tеx] and [/tеx], you can type $$ and $$.

For example

Code:
The equation ##x+2=3## implies $$x=1.$$

Will yield:

The equation ##x+2=3## implies $$x=1.$$

Any comments?
 
  • #75
Looks good to me. (And I don't think the slowness that AlephZero experienced can have been caused by the use of the Verdana font).
 
  • #76
At the very beginning of the FAQ we have this statement:

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.

But it is enough to right click on the equation and select Show Source from the local menu.
 
  • #77
Borek said:
But it is enough to right click on the equation and select Show Source from the local menu.
I prefer the statement we have, because when they click QUOTE they also see what tags we used, and if we typed spaces or newlines before or after. And the right-click thing is explained at the end, under "additional information", where we say "A right-click will display a menu where you can choose to" followed by a list where the first item is "view the LaTeX source code".

Also, this is rarely an issue, but if a person used a \newcommand in his first latex formula in the post, and then used the new command in the second, someone who just looks at the source code won't see the code that defines the code he sees. (I would recommend against using \newcommand like that, because if someone quotes a formula where the command is used but not defined, on a different page of the thread, then (I assume) that the formula won't be displayed correctly. If you want to use \newcommand, I recommend including the definition with every formula that uses it.)
 
Last edited:
  • #78
Borek said:
But it is enough to right click on the equation and select Show Source from the local menu.
If you want to see the code for several different equations, it's easier to use the Quote method.
 
  • #79
FYI, I have edited post #1 of this thread to contain a link to the publicly viewable FAQ thread.
 

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