LyX ⇒ Chemical formulas in LyX
Chemical formulas in LyX
Is there anything in LyX for writing chemical formulas and equasions, similar to Math toolbar?
NEW: TikZ book now 40% off at Amazon.com for a short time.

-
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
Chemical formulas in LyX
Not that I know of. Are you thinking of the 'A + B -> C' sort of thing or something more complex? The standard LaTeX approach to simple equations is to use mhchem.
Joseph Wright
Chemical formulas in LyX
I tried to request mhchem after installing it with mpm, but got the following:
! LaTeX Error: File `mhchem.sty' not found.
\usepackage[version=3]{mhchem}
! LaTeX Error: File `mhchem.sty' not found.
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Chemical formulas in LyX
Called, restarted LyX, still the same error.Stefan_K wrote:Call Tools / Reconfigure in the LyX menu,
Stefan
Searching for the file mhchem.sty, I found it under
~/miktex-texmf/tex/latex/mhchem
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Chemical formulas in LyX
Perhaps LyX could not find it. Try to locate the main MiKTeX folder and install it there, perhaps it would work also if you save it to the same directory where your .lyx document is.
Stefan
Stefan
LaTeX.org admin
Chemical formulas in LyX
That would be strange, as that is the main folder, all other modules are installed there too, including KOMO script which does load.Stefan_K wrote:Perhaps LyX could not find it. Try to locate the main MiKTeX folder and install it there, perhaps it would work also if you save it to the same directory where your .lyx document is.
Stefan
Anyway, keeping sty file in the same folder works.
Chemical formulas in LyX
I can't seem to be able to get gas arrow to work.
Precipitate works fine as per below, but gas renders as ^.
Also, <-> works, but not <=>>
<-> renders into two double headed arrow.
<=>> should render into a longer left arrow with shorter right arrow underneath, but it renders into two opposing arrows of equal length, followed by degree and > sign.
Precipitate works fine as per below, but gas renders as ^.
Precipitate and Gas
Use v or (v) for precipitate (arrow down) and ^ or (^) for gas (arrow up), both separated by
spaces.
SO2–
4 +Ba2+ !BaSO4 # \ce{SO4^2- + Ba^2+ -> BaSO4 v}
NaClO + 2H2O > NaClO3 + 2H2 ^
Also, <-> works, but not <=>>
<-> renders into two double headed arrow.
<=>> should render into a longer left arrow with shorter right arrow underneath, but it renders into two opposing arrows of equal length, followed by degree and > sign.
Chemical formulas in LyX
This is why gas symbol does not work in chemical equasions under LyX.
It converts ^ symbol into \textasciicircum{}:
Only after exporting Lyx file to plain LaTeX I figured what was going on.
I need to render those symbols - how?
Further, import of a tex file containing this
results in the ^ character being dropped from the source completely. Is that by design?
This is what the same line looks in LyX after import:
It converts ^ symbol into \textasciicircum{}:
\ce{2NaCl + 2H2O -> H2 \textasciicircum{} + Cl2 \textasciicircum{}
+ 2NaOH
Only after exporting Lyx file to plain LaTeX I figured what was going on.
I need to render those symbols - how?
Further, import of a tex file containing this
\ce{ 2NaOH + Cl2 -> 2NaClO + H2 ^}
results in the ^ character being dropped from the source completely. Is that by design?
This is what the same line looks in LyX after import:
\ce{ 2NaOH + Cl2 -> 2NaClO + H2 }
Re: Chemical formulas in LyX
Apparenlty this is a bug in LyX, it is not treating the symbols correctly.