Introducing LaTeX Math Typesetting

In summary, Physicsforums.com has introduced the addition of LaTeX mathematical typesetting to their forum software. This professional-grade typesetting system allows for pleasing mathematical presentation and can be included in any post on the forum. Users can include LaTeX graphics by using the [ tex ]...[ /tex ] or [ itex ]...[ /itex ] tags, with the latter being used for inline graphics. The forum provides a pdf file and symbol reference for the most useful LaTeX commands, symbols, and constructs. The amsmath package is also available for more information. Examples of various techniques are provided, including subscripts, superscripts, and equations. Users can also use the [ tex usepackage= ] tag to include additional packages.
  • #1
chroot
Staff Emeritus
Science Advisor
Gold Member
10,296
41
Please go to this post for help with the current version of LaTeX used at Physics Forums.
Note: while the thread that follows has become outdated, many of the examples it contains are still relevant.

Physicsforums.com is proud to introduce the addition of LaTeX mathematical typesetting to our forum software!

LaTeX is a professional-grade general typesetting system that centers around very pleasing mathematical presentation. Mathematical expressions are written in a markup style somewhat similar to HTML.

You may include LaTeX graphics in any post here on physicsforums.com (but not in private messages).

To include a LaTeX graphic, simply include your LaTeX code within the tags [ tex ] [ / tex ] or [ itex ] [ / itex ] for inline. The real tags do not include spaces.

For example, the code
Code:
[ tex ] a^x_n [ /tex ]
produces the graphic [tex]a^x_n[/tex].

Note that you can click on any LaTeX image and see a popup containing the code for the image.

A pdf file of the most useful LaTeX commands, symbols, and constructs is provided here:

https://www.physicsforums.com/misc/howtolatex.pdf

More symbol reference:

http://amath.colorado.edu/documentation/LaTeX/Symbols.pdf

A bit more information on the amsmath package is available here:

http://www.cds.caltech.edu/~dunbar/docs/amsldoc.pdf

Below, I'm providing some example graphics demonstrating a variety of techniques. Click on each to view its source code.

[tex]
\frac{1}{2}
[/tex]

[tex]
R^a{}_{bcd}
[/tex]

[tex]
\nabla \times C
[/tex]

[tex]
\mathbb{RC}
[/tex]

[tex]\lambda_j = \vec{\lambda} \cdot \vec{e}_j[/tex]

[tex]\lambda_j = \mathbf{\lambda} \cdot \mathbf{e}_j[/tex]

[tex]
v(t) = v_0 + \frac{1}{2} a t^2
[/tex]

[tex]
\gamma \equiv \frac{1}{\sqrt{1 - v^2/c^2}}
[/tex]

[tex]
\ddot{x} = \frac {d^2x} {dt^2}
[/tex]

[tex]
\overline{x}
\hat{x}
\check{x}
\tilde{x}
\acute{x}
\grave{x}
\dot{x}
\ddot{x}
\breve{x}
\bar{x}
\vec{x}
\underline{x}
[/tex]

[tex]
\begin{align*}
ab\\
a b\\
a\! b\\
a\, b\\
a\: b\\
a\; b\\
\end{align*}
[/tex]

[tex]
\begin{multline*}
a + b + c + d + e + f\\
+g+h+i+j+k+l+m+n
\end{multline*}
[/tex]

[tex]
\begin{gather*}
a_1 = b_1 + c_1\\
a_2 = b_2 + c_2 - d_2 + e_2
\end{gather*}
[/tex]

[tex]
e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty} (1+x/n)^n
[/tex]

[tex]
\int_{0}^{1} x dx = \left[ \frac{1}{2}x^2 \right]_{0}^{1} = \frac{1}{2}
[/tex]

[tex]
L = \int_a^b \left( g_{\it ij} \dot u^i \dot u^j \right)^{1/2} dt
[/tex]

[tex]
\iiint f(x,y,z)\,dx\,dy\,dz
[/tex]

[tex]
\lim_{\substack{x\rightarrow 0\\y\rightarrow 0}} f(x,y)
[/tex]

[tex]
\idotsint_\textrm{paths} \exp{(iS(x,\dot{x})/\hbar)}\, \mathcal{D}x
[/tex]

[tex]
A \alpha B \beta \Gamma \gamma \Delta \delta \dots \Phi \phi X \chi \Psi \psi \Omega \omega
[/tex]

[tex]
\Gamma^l_{ki} = \frac{1}{2} g^{lj} (\partial_k g_{ij} + \partial_i g_{jk} - \partial_j g_{ki})
[/tex]

[tex]
\sigma_{3} = \left(
\begin{array}{cc}
1 & 0\\
0 & -1
\end{array}
\right)
[/tex]

[tex]
\begin{align*}
u &= \ln x \quad & dv &= x\,dx \\
du &= \mbox{$\frac{1}{x}\,dx$} & v &= \mbox{$\frac{1}{2} x^2$}
\end{align*}
[/tex]

[tex]
\newcommand{\pd}[3]{ \frac{ \partial^{#3}{#1} }{ \partial {#2}^{#3} } }

i \hbar \pd{\Psi}{t}{} =
- \frac{\hbar^2}{2 m} \ \pd{\Psi}{x}{2} + V \Psi
[/tex]

[tex]
\newcommand{\mean}[1]{{<\!\!{#1}\!\!>}}
\newcommand{\braket}[2]{{<\!\!{#1|#2}\!\!>}}
\newcommand{\braketop}[3]{{<\!\!{#1|\hat{#2}|#3}\!\!>}}

\braket{\phi}{\psi} \equiv \int \phi^*(x) \psi(x)\,dx
[/tex]

[tex]
\begin{array}{l | c|c|c|c |} \ &\overline{A}\,\overline{B}&A\,\overline{B}&\overline{A}\, B&A\, B\\
\hline
\overline{C}&0&1&0&0\\
\hline C&1&0&1&1\\
\hline
\end{array}
[/tex]

[tex]
\begin{equation*}
\begin{split}
\tau &= \tau_1+\tau_2 = \sqrt{{\Delta t_1}^2-{\Delta x_1}^2}+
\sqrt{{\Delta t_2}^2-{\Delta x_2}^2} \\
&= \sqrt{(5-0)^2-(4-0)^2}+\sqrt{(10-5)^2-(0-4)^2}\\
&= 3+3 = 6
\end{split}
\end{equation*}
[/tex]

Whenever you want to include a graphic on the same line with your text, like [itex]C H_4[/itex] or [itex]G_\textrm{diffeo}[/itex] or [itex]y = mx + b[/itex], you should use [ itex ]...[ /itex ] instead of [ tex ]...[ /tex ]. The "i" means "inline."

Click on each of the examples above to "learn by example."

If you have questions or comments about this site addition, you are welcome to post them here!

Good luck, and enjoy the system. Please test here: http://at.org/~cola/tex2img/index.php

- Warren
 
Last edited by a moderator:
  • Like
Likes ScienceIsMyLady and (deleted member)
Physics news on Phys.org
  • #2
Subscripts and superscripts

Better:

[tex]
\Gamma^l_{ki} = \frac{1}{2} g^{lj} (\partial_k g_{ij} + \partial_i g_{jk} - \partial_j g_{ki})
[/tex]

Italicizing subscripts is unnecessary when those subscripts are variables and such; on the other hand, if they're words, you want to switch to text formatting instead of equation formatting.

Examples of subscripting/superscripting:

Good:

[tex]
x_i
[/tex]

[tex]
G_{ij}
[/tex]

Bad:

[tex]
G_{diffeo}
[/tex]

Good:

[tex]
G_\textit{diffeo}
[/tex]
[tex]
G_\textrm{diffeo}
[/tex]

Bad:

[tex]
R^a_{bcd}
[/tex]

Good:

[tex]
R^a{}_{bcd}
[/tex]

Okay:

[tex]
x_i^2
[/tex]

Maybe better:

[tex]
{x_i}^2
[/tex]
 
Last edited:
  • #3
Some more examples:

[tex]
{\cal L}_R = \sum_{i=1}^G
\bar{E}^i_R(i\kern+0.1em /\kern-0.55em \partial
- g_1Y_E \kern+0.1em /\kern-0.65em B)E^i_R +
\bar{D}^i_R(i\kern+0.1em /\kern-0.65em D
- g_1Y_D \kern+0.1em /\kern-0.65em B)D^i_R +
\bar{U}^i_R(i\kern+0.15em /\kern-0.65em D
- g_1Y_U \kern+0.1em /\kern-0.65em B)U^i_R
[/tex]

[tex]V = \left( \begin{array}{ccc}
1-\frac{1}{2}\lambda^2 & \lambda & A\lambda^3(\rho-i\eta) \\
-\lambda & 1-\frac{1}{2}\lambda^2 & A\lambda^2 \\
A\lambda^3(1-\rho-i\eta) & -A\lambda^2 & 1
\end{array} \right) + {\cal O}(\lambda^4)
[/tex]

[tex]
\newcommand{\colv}[2] {\left(\begin{array}{c} #1 \\ #2 \end{array}\right)}
L_L &=& \left(
{\colv{\nu_e}{e}}_L,
{\colv{\nu_\mu}{\mu}}_L,
{\colv{\nu_\tau}{\tau}}_L\,
\right), \qquad Y_L = -\frac{1}{2}
[/tex]

[tex]
\newcommand{\colv}[2] {\left(\begin{array}{c} #1 \\ #2 \end{array}\right)}
Q_L &=& \left(
{\colv{u}{d}}_L,
{\colv{c}{s}}_L,
{\colv{t}{b}}_L\,
\right), \qquad\quad\ Y_Q = \frac{1}{6}
[/tex]
 
Last edited:
  • #4
[tex]
\def\pds{\kern+0.1em /\kern-0.55em \partial}
\def\lts#1{\kern+0.1em /\kern-0.65em #1}
{\cal L}_R = \sum_{i=1}^G
\bar{E}^i_R(i\pds
- g_1Y_E \lts{B})E^i_R +
\bar{D}^i_R(i\lts{D}
- g_1Y_D \lts{B})D^i_R +
\bar{U}^i_R(i\lts{D}
- g_1Y_U \lts{B})U^i_R)
[/tex]

There's actually a whole 'slashed' package for this...
 
  • #5
Feel free to propose a list of packages to be included here. I don't want to include tooooo many, for fear of slowing down image generation unnecessarily. On the other hand, I may eventually make the tag

[ tex usepackage=apackage,anotherpackage ] [ /tex ]

or similar.

- Warren
 
  • #6
Lemme try.
[tex]
H_1 = - {\sin \phi - \sin \phi_{\rm s}\over \beta c} \,
\sum_{j} e V_j \delta
(\theta -\theta_j) \left(D\,{p_x\over p_0} - D'x \right)
[/tex]
Way cool. Say, can I use this (write a tex in physicsforums, preview it, save the resulting png, ...) to generate png's for my own web pages?
 
  • #7
Originally posted by krab
Way cool. Say, can I use this (write a tex in physicsforums, preview it, save the resulting png, ...) to generate png's for my own web pages?
You can, but try not to bog the server down too much. If you'd like to see the source code for the conversion process so you can run it on your own machine, pm me.

- Warren
 
  • #8
Originally posted by krab
Say, can I use this (write a tex in physicsforums, preview it, save the resulting png, ...) to generate png's for my own web pages? [/B]

I don't wish to burst your bubble krab, but please don't do this. The LaTeX generator was made for use strictly on PF. The resources needed to make these graphics can be relatively demanding.
 
  • #9
  • #10
Brilliant! now excuse me while I just get a little practice

[tex]e^+e^-\rightarrow u \bar{u}[/tex]

[tex]e^+e^-\rightarrow \mu^+\mu^-[/tex]

[tex]e^+e^-\rightarrow \gamma\gamma[/tex]

[tex]i\hbar\frac{\partial\Psi}{\partial t} = \frac{\hbar^2}{2m}\frac{\partial^2\Psi}{\partial x^2} + V\Psi[/tex]
 
Last edited:
  • #11
Here's a question:

I know how to write:

[tex]
\lim_{x\rightarrow 0} f(x)
[/tex]

But how do I get two levels of subscripting here? For instance, if I want to write

[tex]
\lim_{x\rightarrow 0,~y \rightarrow 0} f(x, y)
[/tex]

but have a two-line subscript instead of a long one-line subscript?
 
  • #12
[tex]
\lim_{\substack{x\rightarrow 0\\y\rightarrow 0}} f(x,y)
[/tex]
 
  • #13
is not another way?..

in fct it seems to complicate for me ..are there equation editors for latex?..i mean programs to write math simbols without knowing nothing of latex and a button to write integrals and limits
 
  • #14
It's actually quite simple, I've never used it before, but reading through the tutorial it only took me a couple of minutes to work out how to write the simple equations above. Just try messing around with it to get a little practice. Quote the integral below to see the code for it:

[tex]
\int_{0}^{1} \frac{x}{\sqrt{a^2 + x^2}} dx = \left[ \sqrt{a^2 + x^2} \right]_{0}^{1}
[/tex]
 
  • #15
Originally posted by jcsd
Quote the integral below to see the code for it:
Small tip you may have overlooked jcsd: you can simply click on any LaTeX image to get a popup window displaying its code.

- Warren
 
  • #16
Just write down the regular formula on a piece of paper and one by one write down the code in the browser, it is really easy that way! Try a few simple things and the code that looked so incredibly overwhelming a few minutes ago, will look very logical :)
 
  • #17
I didn't realize that Chroot, I had Pop-up Stopper on :smile:
 
  • #18
scientific notebook let's you create things that look like math but when you save it, it's in tex (or latex?). I'm looking for other equation editors myself because there is one thing i don't like about scientific notebook.

how does one go about adding tex capabilities to their message board?
 
  • #19
Lets have a go...

[tex]2\pi\sqrt{l/g}[/tex]


[tex]\gamma \equiv \frac{1}{\sqrt{1 - v^2/c^2}}[/tex]


edit: After three attempts I got it to work!
:smile:
 
Last edited:
  • #20
Displaying vectors can be tricky.

The default \vec LaTeX command produces a little arrow over the top of vectors, e.g.

[tex]\lambda_j = \vec{\lambda} \cdot \vec{e}_j[/tex]

If you'd prefer to make your vectors boldface, just redefine the \vec command. See the source for this image to see how the command is redefined.

[tex]
\renewcommand{\vec}[1]{\mbox{\boldmath $ #1 $}}

\lambda_j = \vec{\lambda} \cdot \vec{e}_j[/tex]

- Warren
 
  • #21
does this always generate display mode, or can we make it do inline mode as well?
 
  • #22
Originally posted by lethe
does this always generate display mode, or can we make it do inline mode as well?
You mean, can you typeset your entire post in TeX and use $ $ to set off the math?

- Warren
 
  • #23
Originally posted by chroot
You mean, can you typeset your entire post in TeX and use $ $ to set off the math?

- Warren

no, LaTeX has two modes, one for displaying equations inline (with $...$), where stuff is smaller, and another for display mode equations (\[ ... \]). the same equation will display differently depending on which you use. can we have access to both methods?
 
  • #24
Originally posted by lethe
no, LaTeX has two modes, one for displaying equations inline (with $...$), where stuff is smaller, and another for display mode equations (\[ ... \]). the same equation will display differently depending on which you use. can we have access to both methods?
In what way are equations displayed differently in these two modes? AFAIK, math is displayed the same way in between $$ as in the displaymath environment.

- Warren
 
  • #25
Display math:

[tex]\sum_i x^i[/tex]

(inline) math, [tex]\mbox{$\sum_i x^i$}[/tex], hacked
 
  • #26
Originally posted by chroot
In what way are equations displayed differently in these two modes? AFAIK, math is displayed the same way in between $$ as in the displaymath environment.

The 'displaymath' environment is the same as $$...$$, to show equations on a line by themselves, but $...$ is the 'math' environment, which is intended for equations inlined with other text.
 
  • #27
Ambi,

Cool, I tried a few things and couldn't find anything that displayed differently!

Using \mbox is a fine way to do it.

- Warren
 
  • #28
If it becomes a serious wishlist item for a lot of people, I can consider adding some attributes like mode=displaymath or mode=inline to the [ tex ] tag. Otherwise, \mbox is the easiest way to accomplish it.

- Warren
 
  • #29
Originally posted by chroot
Ambi,

Cool, I tried a few things and couldn't find anything that displayed differently!

yeah, neither could i, because apparently the software doesn t recognize the inline mode commands...

Using \mbox is a fine way to do it.

OK, good enough
 
  • #30
Originally posted by lethe
yeah, neither could i, because apparently the software doesn t recognize the inline mode commands...
No, I tried \mbox too -- but I tried y = mx + b, which looks the same in both environments, lol:

[tex]y = m x + b[/tex]

[tex]\mbox{ $ y = m x + b $ }[/tex]

- Warren
 
  • #31
Originally posted by chroot
Otherwise, \mbox is the easiest way to accomplish it.

- Warren

do we have the amsmath package? mbox is a little limited, (like it doesn t go into subscripts very well), and \text is better.
 
  • #32
Originally posted by chroot
No, I tried \mbox too -- but I tried y = mx + b, which looks the same in both environments, lol:

yeah, i think the only place where this makes a difference is for larger things like fractions, summations and integrations.
 
  • #33
Originally posted by chroot
If it becomes a serious wishlist item for a lot of people, I can consider adding some attributes like mode=displaymath or mode=inline to the [ tex ] tag. Otherwise, \mbox is the easiest way to accomplish it.

It seems to me that typing "\mbox{}" is still easier than typing "mode=inline" ...
 
  • #34
Yes, we have amsmath; I only recently started using it, so I keep forgetting about it...

However, if you're proposing \text as a replacement for \mbox in this instance ...

[tex]\mbox{$\sum_i x^i$}[/tex]
[tex]\text{$\sum_i x^i$}[/tex]
 
  • #35
Originally posted by lethe
do we have the amsmath package? mbox is a little limited, (like it doesn t go into subscripts very well), and \text is better.

apparently not.
 

Similar threads

Replies
5
Views
1K
Replies
3
Views
1K
Replies
4
Views
2K
Replies
8
Views
2K
Replies
3
Views
878
Replies
2
Views
1K
Back
Top