Hi,
you should put in the Preamble (Preferences, last entry) the following
code: \usepackage[version=4]{mhchem}
To insert the code (\ce{H2O}, please use (Main menu) Insert > TeX Code
(red box).
Then create pdf.
This has nothing to do with the math mode.
Regards
Jürgen
Am 09.08.2016, 16:41 Uhr, schrieb Bernt Lie
I’m new to LyX, and try to typeset chemical formulae using package
mhchem. It is not quite clear from “LyX’s detailed Math manual” of July
5, 2016 how to use mhchem, though.
Preliminaries:
· I use Windows 10 + LyX 2.2.1
· I *assume* that package mhchem is installed when I specify to
“Load always” “mhchem” under Math Options of the Document Settings. [The
documentation recommends that >“the LaTeX-package mhchem is installed” –
but assumes that the user knows how to install the package.]
· From the log when I typeset the document, it appears as if
package mhchem, version 4.04 is used.
Problem:
· I have assumed that the command “\ce” is to be used in math
mode, i.e., first use Ctrl+m to switch to math mode, then type “\ce “
(including the space after “\ce”) to get the >“new blue box” that is
mentioned in section 20, p. 57 of document “LyX’s detailed Math manual”.
· Assume that I want to typeset the chemical symbol for water,
H2O – but with the number (“2”) in subscript.
· So I type Ctrl+m, and then “\ce “, and then “H2O”... but it
does not preview as H_2O. Shouldn’t it? Is it only in the output/PDF
file that I see it correctly typeset?
· According to Martin Hensel’s documentation for mhchem, version
4.05, I can also typeset chemical expressions in text mode. I assume
that I have to insert the “\ce{xxx}” >expression into a TeX code to
achieve this?
Thanks!
-Bernt L.