LaTeX Introducing LaTeX Math Typesetting

AI Thread Summary
Physics Forums has integrated LaTeX mathematical typesetting into its platform, allowing users to create visually appealing mathematical expressions using markup similar to HTML. Users can include LaTeX graphics in posts by wrapping their code in [tex] or [itex] tags for display or inline formatting, respectively. A PDF guide with essential LaTeX commands and symbols is available, along with links to additional resources. The community is encouraged to experiment with the system and share examples, while also being mindful of server load when generating graphics. This addition aims to enhance the clarity and professionalism of mathematical discussions on the forum.
chroot
Staff Emeritus
Science Advisor
Gold Member
Messages
10,266
Reaction score
45
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 a^x_n.

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.

<br /> \frac{1}{2}<br />

<br /> R^a{}_{bcd}<br />

<br /> \nabla \times C<br />

<br /> \mathbb{RC}<br />

\lambda_j = \vec{\lambda} \cdot \vec{e}_j

\lambda_j = \mathbf{\lambda} \cdot \mathbf{e}_j

<br /> v(t) = v_0 + \frac{1}{2} a t^2<br />

<br /> \gamma \equiv \frac{1}{\sqrt{1 - v^2/c^2}}<br />

<br /> \ddot{x} = \frac {d^2x} {dt^2}<br />

<br /> \overline{x}<br /> \hat{x}<br /> \check{x}<br /> \tilde{x}<br /> \acute{x}<br /> \grave{x}<br /> \dot{x}<br /> \ddot{x}<br /> \breve{x}<br /> \bar{x}<br /> \vec{x}<br /> \underline{x}<br />

<br /> \begin{align*}<br /> ab\\<br /> a b\\<br /> a\! b\\<br /> a\, b\\<br /> a\: b\\<br /> a\; b\\<br /> \end{align*}<br />

<br /> \begin{multline*}<br /> a + b + c + d + e + f\\<br /> +g+h+i+j+k+l+m+n<br /> \end{multline*}<br />

<br /> \begin{gather*}<br /> a_1 = b_1 + c_1\\<br /> a_2 = b_2 + c_2 - d_2 + e_2<br /> \end{gather*}<br />

<br /> e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty} (1+x/n)^n<br />

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

<br /> L = \int_a^b \left( g_{\it ij} \dot u^i \dot u^j \right)^{1/2} dt<br />

<br /> \iiint f(x,y,z)\,dx\,dy\,dz<br />

<br /> \lim_{\substack{x\rightarrow 0\\y\rightarrow 0}} f(x,y)<br />

<br /> \idotsint_\textrm{paths} \exp{(iS(x,\dot{x})/\hbar)}\, \mathcal{D}x<br />

<br /> A \alpha B \beta \Gamma \gamma \Delta \delta \dots \Phi \phi X \chi \Psi \psi \Omega \omega<br />

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

<br /> \sigma_{3} = \left(<br /> \begin{array}{cc}<br /> 1 &amp; 0\\<br /> 0 &amp; -1<br /> \end{array}<br /> \right)<br />

<br /> \begin{align*}<br /> u &amp;= \ln x \quad &amp; dv &amp;= x\,dx \\<br /> du &amp;= \mbox{$\frac{1}{x}\,dx$} &amp; v &amp;= \mbox{$\frac{1}{2} x^2$}<br /> \end{align*}<br />

<br /> \newcommand{\pd}[3]{ \frac{ \partial^{#3}{#1} }{ \partial {#2}^{#3} } }<br /> <br /> i \hbar \pd{\Psi}{t}{} =<br /> - \frac{\hbar^2}{2 m} \ \pd{\Psi}{x}{2} + V \Psi<br />

<br /> \newcommand{\mean}[1]{{&lt;\!\!{#1}\!\!&gt;}}<br /> \newcommand{\braket}[2]{{&lt;\!\!{#1|#2}\!\!&gt;}}<br /> \newcommand{\braketop}[3]{{&lt;\!\!{#1|\hat{#2}|#3}\!\!&gt;}}<br /> <br /> \braket{\phi}{\psi} \equiv \int \phi^*(x) \psi(x)\,dx<br />

<br /> \begin{array}{l | c|c|c|c |} \ &amp;\overline{A}\,\overline{B}&amp;A\,\overline{B}&amp;\overline{A}\, B&amp;A\, B\\<br /> \hline<br /> \overline{C}&amp;0&amp;1&amp;0&amp;0\\<br /> \hline C&amp;1&amp;0&amp;1&amp;1\\<br /> \hline<br /> \end{array}<br />

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

Whenever you want to include a graphic on the same line with your text, like C H_4 or G_\textrm{diffeo} or y = mx + b, 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
Some more examples:

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

V = \left( \begin{array}{ccc}<br /> 1-\frac{1}{2}\lambda^2 &amp; \lambda &amp; A\lambda^3(\rho-i\eta) \\<br /> -\lambda &amp; 1-\frac{1}{2}\lambda^2 &amp; A\lambda^2 \\<br /> A\lambda^3(1-\rho-i\eta) &amp; -A\lambda^2 &amp; 1<br /> \end{array} \right) + {\cal O}(\lambda^4)<br />

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

<br /> \newcommand{\colv}[2] {\left(\begin{array}{c} #1 \\ #2 \end{array}\right)}<br /> Q_L &amp;=&amp; \left(<br /> {\colv{u}{d}}_L,<br /> {\colv{c}{s}}_L,<br /> {\colv{t}{b}}_L\,<br /> \right), \qquad\quad\ Y_Q = \frac{1}{6}<br />
 
Last edited:
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
 
Lemme try.
<br /> H_1 = - {\sin \phi - \sin \phi_{\rm s}\over \beta c} \, <br /> \sum_{j} e V_j \delta<br /> (\theta -\theta_j) \left(D\,{p_x\over p_0} - D&#039;x \right)<br />
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?
 
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
 
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.
 
Brilliant! now excuse me while I just get a little practice

e^+e^-\rightarrow u \bar{u}

e^+e^-\rightarrow \mu^+\mu^-

e^+e^-\rightarrow \gamma\gamma

i\hbar\frac{\partial\Psi}{\partial t} = \frac{\hbar^2}{2m}\frac{\partial^2\Psi}{\partial x^2} + V\Psi
 
Last edited:
Here's a question:

I know how to write:

<br /> \lim_{x\rightarrow 0} f(x)<br />

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

<br /> \lim_{x\rightarrow 0,~y \rightarrow 0} f(x, y)<br />

but have a two-line subscript instead of a long one-line subscript?
 
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:

<br /> \int_{0}^{1} \frac{x}{\sqrt{a^2 + x^2}} dx = \left[ \sqrt{a^2 + x^2} \right]_{0}^{1}<br />
 
  • #10
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
 
  • #11
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 :)
 
  • #12
I didn't realize that Chroot, I had Pop-up Stopper on :smile:
 
  • #13
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?
 
  • #14
Lets have a go...

2\pi\sqrt{l/g}


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


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

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

\lambda_j = \vec{\lambda} \cdot \vec{e}_j

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.

<br /> \renewcommand{\vec}[1]{\mbox{\boldmath $ #1 $}} <br /> <br /> \lambda_j = \vec{\lambda} \cdot \vec{e}_j

- Warren
 
  • #16
does this always generate display mode, or can we make it do inline mode as well?
 
  • #17
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
 
  • #18
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?
 
  • #19
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
 
  • #20
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
 
  • #21
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
 
  • #22
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
 
  • #23
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:

y = m x + b

\mbox{ $ y = m x + b $ }

- Warren
 
  • #24
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.
 
  • #25
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.
 
  • #26
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.
 
  • #27
Originally posted by Ambitwistor
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 ...

yes, it doesn t work... i assume that is because amsmath isn t loaded... or?
 
  • #28
chroot-

on the pdf how-to provided on the first post of this thread, it states that [ tex ] is equivalent to $...$ (which makes inline math mode), but i guess what we have discovered here, is that it is actually equivalent to \[ ...\] (which makes display mode math).

perhaps the pdf can be updated?
 
  • #29
Originally posted by lethe
. i assume that is because amsmath isn t loaded... or?

it seems that amsmath is loaded after all.
 
  • #30
Yes, amsmath & amssymb are in fact available.

The code you type into [ tex ] tags goes directly into a \begin{displaymath}...\end{displaymath} environment. This can be changed if necessary. I assumed the majority of users would be putting equations set apart from their text, but this may not be a good assumption. I believe \mbox effectively just steps out it without any downsides.

- Warren
 
  • #31
<br /> Hrm,~line~breaks \\<br /> don&#039;t~seem~to~work.<br />
 
  • #32
All right, here's a new problem. How do I do this, but right?

<br /> \begin{array}{r l r l}<br /> u &amp;= \ln x \quad &amp; dv &amp;= x\,dx \\<br /> du &amp;= \frac{1}{x}\,dx &amp; v &amp;= \frac{1}{2} x^2<br /> \end{array}<br />
 
  • #33
Originally posted by Hurkyl
All right, here's a new problem. How do I do this, but right?

i don t understand... what are you trying to do?
 
  • #34
There's too much space to the left of the equal signs. u=\ln x "should" be one entity instead of being spread over two separate columns.
 
  • #35
If I want to denote the real and complex sets, using one of the below fonts which looks better?

\mathbb{RC}\mathbbmss{RC}\mathds{RC}

edited to add: it doesn't look like we have the other two fonts. There must be someway of represintg the real and complex sets in this manner, as the first fonts don't really look right to me.
 
Last edited:
  • #36
I was just hpoing to get something more inline with what's in my textbooks, but I suppose the font is more than adequate.
 
  • #38
Actually, you can specify that images should be centered vertically within the line of text they're in -- I'm working on getting that attribute into the image tags. Politics, shmolitics.

- Warren
 
  • #39
I just remembered that for simple annotations as that the sub and sup tags can be used :)
 
  • #40
Update!

The LaTeX code has been improved a bit. I know you guys have been frustrated with the ugliness of inline TeX, so I went ahead and improved that.

I have introduced a new LaTeX command, the \inline command. Whenever you want to include a graphic inline with your text, like \inline{C H_4} or \inline{G_\textrm{diffeo}} or \inline{y = mx + b}, you should use the \inline{...} construct. Remember: click the LaTeX images to see how they're implemented.

Of course, you can inline larger pieces of TeX too, like \inline{\frac{1}{\sqrt{1 - v^2/c^2}}} or even \inline{e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty} (1+x/n)^n<br /> }. But if makes more sense to include larger graphics set apart from your text, like this:

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

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

Note the difference in font sizing and layout between the normal and inlined graphics.

In addition, I have changed the TeX \vec command to boldface vectors. So feel free to use expressions like \inline{\vec{F} = m \vec{a}} to denote vector quantities.

Enjoy!

- Warren
 
  • #41
How do I get the arrows, then, if I want them?
 
  • #42
Originally posted by Hurkyl
How do I get the arrows, then, if I want them?
Hmmm well, I thought I knew how, but now I'm not so sure. I'll have to look around. Maybe Ambitwistor knows a trick to put a command that has been \renew'd back to its default behavior.

Also, I found this pdf of useful mathematical constructs, that goes a bit beyond what we already have:

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

- Warren
 
  • #43
Originally posted by Ambitwistor
I don't know how to get a command back to its original behavior. You could try defining a new command to act like the original \vec before you redefine it. (Or else you could leave the original alone and define a new command to act like the bold version.)
Both are good ideas. Generally, boldfacing is the "proper" way to represent vectors. Unfortunately, TeX treats lowercase greek letters and uppercase greek letters differently, making it fairly complicated to just boldface any old character. I put the macro into the system so people wouldn't have to jump through hoops if they just wanted to make a boldface \inline{\vec \lambda}.

Maybe redefining \boldmath to work everywhere is the best approach here, leaving \vec alone.

- Warren
 
  • #44
I also just noticed that in IE6, the inline LaTeX images are a few pixels below the baseline of the text. In my preferred browser, Mozilla, they are exactly correct. Perhaps I need to tweak the site's style sheet to get the line spacing just right in all browsers. I'll have to think about it. In the meantime, everyone should switch to Mozilla Firebird!

- Warren
 
  • #45
Actually, scratch that -- when the font size is set to "Medium" in the view menu, it's just right in IE6 too. (whew) Are any of you experiencing inline LaTeX graphics that are NOT aligned properly with your text?

- Warren
 
  • #46
Also, Ambi, you LaTeX guru you,

Can you tell me why the font size is different between these two images?

\inline{<br /> \int_{a}^{b}} e^x dx<br /> }

\inline{<br /> e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty} (1+x/n)^n<br /> }

Look at the e^x... does the integral sign somehow cause the font size to change, or what?

- Warren
 
  • #47
Originally posted by Hurkyl
How do I get the arrows, then, if I want them?

wouldn t it just be better to follow ams guidlines, and have \vec make an overline, and \mathbf make boldface? i much prefer boldface to arrows in print, but i don t see any reason to override ams defaults to get rid of arrows... they are not that bad...
 
  • #48
What about making a new tag, say, [ itex ] for inline tex? It gets annoying having to type [ tex ]\inline{x}[ /tex ] 10 times in a post!
 
  • #49
Your right it can be annoying, when I posted a load of inline text though, I just copied the commands onto the clipboard and pasted, changing the code between the inline brackets.
 
  • #50
Originally posted by Hurkyl
What about making a new tag, say, [ itex ] for inline tex? It gets annoying having to type [ tex ]\inline{x}[ /tex ] 10 times in a post!
Yeah, I was strongly considering this from the beginning. Next time Greg let's me on the site, I'll do that.

- Warren
 

Similar threads

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