PDA

View Full Version : Chemical LaTeX typeset


Monique
Nov16-03, 02:55 PM
Physicsforums now has a very cool feature, which enables complex typesetting for formulas or equations!

A tutorial is on the following page:
http://www.physicsforums.com/misc/howtolatex.pdf
The topic is also explained in the following thread:
http://www.physicsforums.com/showthread.php?s=&threadid=8997


The feature is LaTeX and the following is possible::

^{33}_{17}Cl^{16}\xrightarrow{n,n}~^{31}_{15}P^{16 }+~^4_2He^2

Not long ago we had to write::
33 (1) 31 4
17 Cl + 2(0)n -----> 15 P + 2 He

Causing much confusion as you can imagine [:D]
So play around with some formulas if you like, click on the LaTeX image to popup the code with which it was written.


To explain the basics:
_ is subscript
^ is superscript
{} are delimiters, to keep text together
~ is a space


So the code in the above formula is::
[ tex]^{33}_{17}Cl^{16}\xrightarrow{n,n}~^{31}_{15}P^{16 }+~^4_2He^2[ /tex]

Monique
Nov16-03, 03:56 PM
Henderson-Hasselbalch equation:

pH=pK_a+log\frac{[A^-]}{[HA]}

Monique
Nov16-03, 04:07 PM
Michaelis-Menten equation

V=\frac{k_2[E]_t[S]}{K_M+[S]}


or


6CO_2+6H_2O\xrightarrow{Light~Energy}C_6H_{12}O_6+ CO_2~~~\Delta G^\circ=+2870kJ/mol


If I can do it, anyone can! [;)]

Ambitwistor
Nov16-03, 04:24 PM
\newcommand{\atom}[ 4 ]{{}^{#1}_{#2} {#3}^{#4}}

\atom{33}{17}{Cl}{16} \xrightarrow{n,n} \atom{31}{15}{P}{16} + \atom{4}{2}{He}{2}


pH = pK_a + \log\frac{[A^-]}{[HA]}


\begin{equation*}
\begin{align}
&6CO_2+6H_2O\xrightarrow{\textit{Light Energy}}C_6H_{12}O_6+CO_2 \\
&\Delta G^\circ=+2870~\textrm{kJ/mol}
\end{align}
\end{equation*}

Monique
Nov16-03, 04:27 PM
Ambitwistor is not such a simple soul as me [;)]

I actually noticed that I am putting in too many spacers (~), those are not always necessary next to '+' or '\xrightarrow' or '='

Ambitwistor
Nov16-03, 04:31 PM
Originally posted by Monique
I actually noticed that I am putting in too many spacers (~), those are not always necessary next to '+' or '\xrightarrow' or '='

In fact, they're almost never necessary; TeX is smart enough in most cases to get the spacing right. If you want to add more spacing, use /, (not ~, that's to prevent line breaks), and if you want to remove spacing, use /; --- but use them sparingly. (There are well-known cases where TeX isn't smart and you need to use them, though; not enough spaces in integrals and too many spaces in bra-kets.)

Jeebus
Nov23-03, 05:37 PM
Enthalpy of Vaporization
The amount of energy to change 1 g of liquid to gas at its boiling point. For water,


\Delta\ H _v_a_p = 540 cal g-^1

Ambitwistor
Nov23-03, 05:50 PM
\Delta H_\textrm{vap} = 540 \mbox{ cal~g}^{-1}

Monique
Nov24-03, 04:32 AM
Good try, Jeebus :)

Next time, instead of writing H _v_a_p

try this: H_{vap}

Another God
Dec6-03, 02:12 AM
OK, exams are over so I have no reason to not learn this stuff now.... here I go.

Moniques version...
^{33}_{17}{Cl}^{16} \xrightarrow{n,n} ^{31}_{15}P^{16} +~^4_2He^2

Ambitwistors version...

\newcommand{\atom} [ 4 ] { ^{#1}_{#2} {#3}^{#4}}
\atom {33}{17}{Cl}{16} \xrightarrow{n,n} \atom {31}{15}{P}{16}+\atom {4}{2}{He}{2}

Another God
Dec6-03, 02:25 AM
{pH} = {pK_a} + \log\frac{[A^-]}{[HA]} \\

V = \frac{k_2{[E]}+{[S]}}{K_m + {[S]}} \\


6CO_2 + 6H_2O \xrightarrow{Light Energy} C_6H_{12}O_6 + CO_2 \ \delta G^{\circ} = +2870kJ/mol



Oh, ok, so \\ can only be used as part of an equation to start a new line. To do different equations, you have to use diferent tex flags i guess...?

And why didn't my C6H12) finish....


{pH} = {pK_a} + \log\frac{[A^-]}{[HA]}

V = \frac{k_2{[E]}_t{[S]}}{K_M + {[S]}}


Now, will this come up as I want it to? 6CO_2 + 6H_2O \xrightarrow{Light Energy} C_6 H_{12} O_6 + CO_2 \delta G^{\circ} = +2870kJ/mol Lets find out...

Another God
Dec6-03, 02:33 AM
wow, capitals matter.

that should have been \Delta not \delta.

So

6CO_2 + 6H_2O \xrightarrow{Light Energy} C_6 H_{12} O_6 + CO_2 ~\Delta G^{\circ} = +2870kJ/mol

Another God
Dec6-03, 02:36 AM
that \ thing never does what I want...6CO_2 + 6H_2O \xrightarrow{Light\Energy} C_6 H_{12} O_6 + CO_2 ~\Delta \ \ \ \G^{\circ} = +2870kJ/mol

Maybe I should use that comma? 6CO_2 + 6H_2O \xrightarrow{Light/,Energy} C_6 H_{12} O_6 + CO_2 ~\Delta /, /, /, G^{\circ} = +2870kJ/mol

6CO_2 + 6H_2O \xrightarrow{Light\,Energy} C_6 H_{12} O_6 + CO_2 ~\Delta \, \, \, G^{\circ} = +2870kJ/mol
I think i prefer the tilde (~) key...6CO_2 + 6H_2O \xrightarrow{Light~Energy} C_6 H_{12} O_6 + CO_2 ~\Delta~~~G^{\circ} = +2870kJ/mol

Ambitwistor
Dec6-03, 12:25 PM
6CO_2 + 6H_2O \xrightarrow{\mathit{Light Energy}} C_6 H_{12} O_6 + CO_2, \Delta G^{\circ} = +2870~\mathrm{kJ/mol}

Monique
Dec6-03, 01:00 PM
You are using itex, that stands for inline?

tex
^{33}_{17}{Cl}^{16} \xrightarrow{n,n} ^{31}_{15}P^{16} +~^4_2He^2

inline
\inline{^{33}_{17}{Cl}^{16} \xrightarrow{n,n} ^{31}_{15}P^{16} +~^4_2He^2}

itex
^{33}_{17}{Cl}^{16} \xrightarrow{n,n} ^{31}_{15}P^{16} +~^4_2He^2

Apparently :) that's cool!

Another God
Dec6-03, 05:25 PM
It would be nice if it did fit inline a little better though. At the moment it sits a little low and disrupts the line below, so it doesn't look quite as neat.

Another God
Dec6-03, 05:26 PM
I stand~corrected. I guess it depends on the physical size of the formula and stuff. It does a good job of fitting it where it can.

chem_tr
Nov6-04, 10:00 AM
Could you give some information about how to use this typeset in another place?

Sirus
Nov25-04, 10:00 PM
If you mean how to use it outside of PF, you need to download a program such as miktex (www.miktex.org).

dextercioby
Nov26-04, 06:10 AM
Thanks for the link,Sirus.Maybe i'll get read of the old Scientific Workplace that i'm using now.

Sirus
Nov27-04, 12:23 AM
For small applications, you can preview a post on PF with the required code in it, then copy and paste the latex into MS Word or another word processing application. This is discouraged, however, to avoid excess traffic on the PF server (copy/pasting Latex is not, after all, the purpose of PF).

GCT
Feb17-05, 01:41 PM
Trying it out,

H^+ _{(aq)} + OH^- _{(aq)} \xrightarrow~H_2 O _{(l)}

GCT
Feb17-05, 01:49 PM
I should be studying,

1/p + 1/q = 1/f

GCT
Feb17-05, 02:04 PM
this is killing me

{\Delta G} = {\Delta G^_o} - RT\textit{lnQ}

from my current physics course
lens maker's equation
\frac{n_1}{p} + \frac{n_2}{q} = (n_1-1) \left[ \frac{1}{R_1} - \frac{1}{R_2} \right]

I'll just do my hw here
\int ( \textit{lnt} )^2 dt

u= ( \textit{lnt} )^2
du=2( \textit{lnt} )( \frac{1}{t} )
dv= dt
v= \int dt = t

\int ( \textit{lnt} )^2 dt = ( \textit{lnt} )^2t - \int 2t( \textit{lnt} )( \frac{1}{t} )

Gokul43201
Feb17-05, 05:50 PM
Anyone (ambitwistor ?) know the symbol for the equilibrium (upper half of right arrow above lower half of left arrow) sign ?

GCT
Feb17-05, 06:38 PM
just trying things out
\xrightarrow{\leftarrow}

I noticed Monique's first post where she had the n,n over the arrow and figured one could go on from there.

\xrightarrow{\xleftarrow}

Gokul43201
Feb17-05, 11:52 PM
Clever ! That'll have to do until I think it's important to hunt this down or someone comes up with a better answer.

chem_tr
Feb18-05, 02:10 PM
If you have already found this, forgive me, but the solution is \rightleftharpoons or \leftrightharpoons as in the following examples:

H_2O \rightleftharpoons H^+ + OH^-

H_2O \leftrightharpoons H^+ + OH^-

Gokul43201
Feb20-05, 11:17 AM
Thanks chem_tr !! :approve:

endeavour
Feb21-05, 03:02 PM
that \ thing never does what I want...6CO_2 + 6H_2O \xrightarrow{Light\Energy} C_6 H_{12} O_6 + CO_2 ~\Delta \ \ \ \G^{\circ} = +2870kJ/mol

Maybe I should use that comma? 6CO_2 + 6H_2O \xrightarrow{Light/,Energy} C_6 H_{12} O_6 + CO_2 ~\Delta /, /, /, G^{\circ} = +2870kJ/mol

6CO_2 + 6H_2O \xrightarrow{Light\,Energy} C_6 H_{12} O_6 + CO_2 ~\Delta \, \, \, G^{\circ} = +2870kJ/mol
I think i prefer the tilde (~) key...6CO_2 + 6H_2O \xrightarrow{Light~Energy} C_6 H_{12} O_6 + CO_2 ~\Delta~~~G^{\circ} = +2870kJ/mol
lol guys, the photosynthesis equation everyone's using is incorrect ;)

briton
Mar1-05, 08:10 AM
F = \frac {1}{4\pi\epsilon_0}\frac{Q_1Q_2}{r^2}
E_p = \frac {Q_1Q_2}{4\pi\epsilon_0(r_1+r_2)}

E_p = \frac {e^2}{4\pi\epsilon_0(2r_0)}

Q = EV \\

Q = eV \\

E_p = \frac {e}{4\pi\epsilon_0(2r_0)} electron volts


E_k = \frac{3}{2}kT
\gamma \equiv \frac{1}{\sqrt{1 - v^2/c^2}}

bomba923
Apr28-05, 10:31 PM
Does anybody know the fancy "capital E" symbol denoting reduction potentials?

I mean, it doesn't seem to be in LaTex---or is it? Where can I get it?

Edit: Is it by any chance a lowercase "xi" ?
That is, a \xi ^\circ ??

GCT
Apr30-05, 12:17 PM
are you referring to emf?

bomba923
Apr30-05, 06:07 PM
Yes!! What is the symbol for it? (the fancy capital E thing)!!??

Is it on LaTex??

GCT
Apr30-05, 06:14 PM
I've seen it here somewhere. You may want to somehow italicize the E within the latex.

just trying things out...

\varepsilon

GCT
Apr30-05, 08:03 PM
I think that should do it, it's \varepsilon, unless anyone else has a better method

bomba923
May1-05, 12:09 AM
I think that should do it, it's \varepsilon, unless anyone else has a better method

Hmm--what about an \xi ^\circ ?

GCT
May1-05, 12:26 PM
I think that most people will undestand that as the standard reduction potential, nevertheless I think that there's a better way to represent it though.

Mad_About_Science
Nov13-05, 06:47 AM
How could I go about using LaTeX on a word/pdf?

Mad_About_Science
Nov20-05, 11:21 AM
Starch~\xrightarrow{amylase}~C_{12}H_{22}O_{11}

Mad_About_Science
Nov20-05, 11:22 AM
Starch~\xrightarrow{amylase}~C_{12}H_{22}O_{11}

TriTertButoxy
Nov27-05, 05:28 PM
The best fancy 'E' I can come up with is
\mathcal{E}
Also, let me try a few more things
\text{C}_6\text{H}_{12}\text{O}_6\, +\, 6\text{ O}_2\, \xrightarrow{\text{heat}}\, 6\text{ H}_2\text{O}\, + \,6\text{ CO}_2
Isn't it better without italicizing the letters?

Borek
Nov28-05, 04:13 PM
It is, but then - not everone is fluent in LaTeX enough :)

10\textrm{K}_{4}\textrm{Fe(CN)}_{6}+122\textrm{KMn O}_{4}+299\textrm{H}_{2}\textrm{SO}_{4}\rightarrow 162\textrm{KHSO}_{4}+5\textrm{Fe}_{2}\textrm{(SO}_ {4}\textrm{)}_{3}+122\textrm{MnSO}_{4}+60\textrm{H NO}_{3}+60\textrm{CO}_{2}+188\textrm{H}_{2}\textrm {O}

That was exported form one of my programs :)

Best,
Borek
--
Chemical calculator (http://www.chembuddy.com/?left=chemical_calculators)s at www.chembuddy.com (http://www.chembuddy.com)
equation balancer and stoichiometry calculator (http://www.chembuddy.com/?left=EBAS&right=equation-balancing-stoichiometry)
pH calculator (http://www.chembuddy.com/?left=BATE&right=basic_acid_titration_equilibria)
concentration conversion (http://www.chembuddy.com/?left=CASC&right=concentration_conversion)

Mattara
Oct1-06, 10:51 AM
^{14}N~+~^{1}n~\xrightarrow~~^{1}H~+~^{14}C

asrafally
Nov2-06, 04:02 PM
V=\frac{k_2[E]_t[S]}{K_M+[S]}

geoffjb
Nov2-06, 05:00 PM
Yes!! What is the symbol for it? (the fancy capital E thing)!!??

Is it on LaTex??
\in

Is this the one you mean?

freakmagnet19
Mar9-07, 03:54 PM
Try this guy:

$\mathcal{E}$

Gokul43201
Mar13-07, 10:10 PM
Please use this thread ONLY to raise and answer queries related to typsetting tex for chemistry. This thread should not be used as a backdoor to test LaTeX.

http://www.physicsforums.com/showthread.php?p=1165946#post1165946

xerxes
Apr27-07, 02:34 PM
Does anyone know how to do a left-right harpoon with labels above and below, I guess like

k1
/________
_________
....k2....../

You know what I mean. I have a reaction going in two directions with a different rate constant in each.

cristo
Apr27-07, 03:55 PM
You mean like this? \rightleftharpoons

edit: i just saw you want labels above and below.. sorry, dont know how to do that!

Well, i found something that may help you: ftp://ctan.tug.org/tex-archive/info/symbols/comprehensive/symbols-a4.pdf page 41.. although it doesnt work on here since I imagine you need some package.

Hootenanny
May10-07, 09:37 AM
Does anyone know how to do a left-right harpoon with labels above and below, I guess like

k1
/________
_________
....k2....../

You know what I mean. I have a reaction going in two directions with a different rate constant in each.
Try this;

\mathop{\leftrightharpoons}^{k_1}_{k_2}

\mathop{\leftrightharpoons}^{k_1}_{k_2}

IITian
Dec23-07, 05:56 AM
Bal^2=sqrt{C_{Gordon_10}}

Crazy Tosser
May13-08, 03:08 PM
dE = dQ-dW

C=\frac{dQ}{MdT}

dQ
dE
dW
M
dT

sorry for spam =(

Borek
Jun3-08, 05:42 PM
I have not used these symbols for ages, not to mention in LaTeX. How should I properly format statement "for each a and b belonging to set P if a<b then ab belongs to set P2"?

My idea was that it shoud be something like

\forall a, b \in P a < b \Rightarrow ab \in P_2

but it looks like something run over by a truck.

Fenn
Jun30-09, 09:13 AM
First post, and it's about LaTeX! I've been working with LaTeX for some time now, and recently started getting serious about typesetting spectroscopic notation. I actually started this post asking a question, but while developing the post, I came across an acceptable answer. As such, the tone of this post will change from question to tip.

I have been trying to typeset any general chemical equation or spectroscopic configuration notation without italics. I have known of the \text{} command, and recently found the \textrm{} command, but both of these complain when there are superscripts, subscripts, or Greek characters within the {} delimiters.

As is shown in this thread, you can easily get away with carefully placing the delimiters and \text{} commands. For example, I want to write the following configuration information:


\text{4f}^{14}\text{6s6p}~^3\text{P}_1


As another example, as was previously posted,

10\textrm{K}_{4}\textrm{Fe(CN)}_{6}+122\textrm{KMn O}_{4}+299\textrm{H}_{2}\textrm{SO}_{4}\rightarrow 162\textrm{KHSO}_{4}+5\textrm{Fe}_{2}\textrm{(SO}_ {4}\textrm{)}_{3}+122\textrm{MnSO}_{4}+60\textrm{H NO}_{3}+60\textrm{CO}_{2}+188\textrm{H}_{2}\textrm {O}


My problem: Although this works, it is quite messy to read for arbitrarily complex expressions. Further, I have to manually ensure this content is in math mode, which can be a pain when applying it to an arbitrary location.

My solution: Use the \mathrm{} command! Here's the same examples, cleaned up a bit using this new command:


\mathrm{4f^{14} 6s 6p ~ ^3P_1}



\mathrm{10 K_4 Fe (CN)_6 + 122 K MnO_4 + 299 H_2 SO_4 \rightarrow 162 K H SO_4 + 5 Fe_2 (SO_4)_3 + 122 Mn SO_4 + 60 H NO_3 + 60 CO_2 + 188 H_2 O}


Even better, define a new command which enforces math mode, as well as this Roman font. something like

\newcommand{\chem}[1]{\ensuremath{\mathrm{#1}}}

and then you can just simply type \chem{H_2 SO_4} wherever you want, both inside or outside of math mode. With proper use of whitespace, the LaTeX markup looks more elegant and easy to read/diagnose in my opinion.

Hope this helps! It definitely helps me!

chemisttree
Jun30-09, 11:03 AM
Hmmmm. I'm not quite sure what you are getting at....

Fenn
Jun30-09, 01:40 PM
Well, take a look at the actual TeX code for the two examples. To compare, here's the original:


10\textrm{K}_{4}\textrm{Fe(CN)}_{6}+122\textrm{KMn O}_{4}+299\textrm{H}_{2}\textrm{SO}_{4}\rightarrow 162\textrm{KHSO}_{4}+5\textrm{Fe}_{2}\textrm{(SO}_ {4}\textrm{)}_{3}+122\textrm{MnSO}_{4}+60\textrm{H NO}_{3}+60\textrm{CO}_{2}+188\textrm{H}_{2}\textrm {O}


and here's the one I propose


%this should go in your preamble somewhere
\newcommand{\chem}[1]{\ensuremath{\mathrm{#1}}}

%and then later, in your document...
\chem{10 K_4 Fe (CN)_6 + 122 K MnO_4 + 299 H_2 SO_4 \rightarrow 162 K H SO_4 + 5 Fe_2 (SO_4)_3 + 122 Mn SO_4 + 60 H NO_3 + 60 CO_2 + 188 H_2 O}


Another advantage is that, should you ever decide that you like italic letters in your formulas, or if you want them bolded or whatever, you can just go edit the \chem definition, and then all instances of that command in your document will take advantage of the global edit.

chemisttree
Jun30-09, 02:53 PM
OK, I'll bite. Placing "\newcommand{\chem}[1]{\ensuremath{\mathrm{#1}}}" within the tex delimiters...

\newcommand{\chem}[1]{\ensuremath{\mathrm{#1}}}

and entering the string you recommended "\chem{10 K_4 Fe (CN)_6 + 122 K MnO_4 + 299 H_2 SO_4 \rightarrow 162 K H SO_4 + 5 Fe_2 (SO_4)_3 + 122 Mn SO_4 + 60 H NO_3 + 60 CO_2 + 188 H_2 O}"

yields,

\chem{10 K_4 Fe (CN)_6 + 122 K MnO_4 + 299 H_2 SO_4 \rightarrow 162 K H SO_4 + 5 Fe_2 (SO_4)_3 + 122 Mn SO_4 + 60 H NO_3 + 60 CO_2 + 188 H_2 O}

versus just entering the string between tex delimiters....

10 K_4 Fe (CN)_6 + 122 K MnO_4 + 299 H_2 SO_4 \rightarrow 162 K H SO_4 + 5 Fe_2 (SO_4)_3 + 122 Mn SO_4 + 60 H NO_3 + 60 CO_2 + 188 H_2 O

Aside from the spacing between the '+' signs, I see no advantage.

Fenn
Jun30-09, 04:39 PM
For the scope of this forum, try this:


(tex)%NOTE: replace ( with [ to use!
\newcommand{\chem}[1]{\ensuremath{\mathrm{#1}}}
\chem{10 K_4 Fe (CN)_6 + 122 K MnO_4 + 299 H_2 SO_4 \rightarrow 162 K H SO_4 + 5 Fe_2 (SO_4)_3 + 122 Mn SO_4 + 60 H NO_3 + 60 CO_2 + 188 H_2 O}
(/tex)


which should work out to look like



\newcommand{\chem}[1]{\ensuremath{\mathrm{#1}}}
\chem{10 K_4 Fe (CN)_6 + 122 K MnO_4 + 299 H_2 SO_4 \rightarrow 162 K H SO_4 + 5 Fe_2 (SO_4)_3 + 122 Mn SO_4 + 60 H NO_3 + 60 CO_2 + 188 H_2 O}


When you put things in the [tex] [/ tex] delimiters here, it looks like it's an isolated environment, and thus any commands you define must be used within that same [tex] [/ tex] delimiter. My point here, although it may be a minor one in retrospect, is that I introduce an italic-free typesetting environment for stuff like chemical formulas or spectroscopic notation, which can work independent of an equation block.

I had assumed this forum was discussing the general application of LaTeX for typesetting chemistry-related stuff. My earlier suggestion of placing the \newcommand{} within the preamble is referring to a LaTeX document, in my case, prepared by MikTeX 2.7.