Hi
Thanks for comment. I’m still confused:

Ø  This has nothing to do with the math mode.

It must have something to do with math mode!?!

·       The feature is described in LyX’s Math Help document (section 20 of 
LyX’s detailed Math manual for LyX v. 2.2.x)

·       As far as I can see, LyX’s Math Help document has *not* included the 
statement you suggest in its Preamble. Instead, it has specified “Load 
automatically” package “mhchem” under “Math Options” in the Document Settings.

·       In the Math Help document, it is stated “After inserting \ce to a 
formula a new blue box appears where chemical formulas can be inserted in an 
intuitive way”. I assume that “to a formula” refers to a math formula??!

·       In Martin Hensel’s document “The mhchem Bundle” dated August 8, 2016, 
he states about his package that “This works in text mode (even in headings) 
and in math mode.”

By playing around with my document, it seems like the chemical expressions are 
correctly typeset in the pdf file both if I insert the \ce expressions in TeX 
code, and in math mode.

However, my *problem* is that in *my* document, the chemical formulas do not 
*preview* within LyX, while in LyX’s Math Help document, the correct 
typesetting seems to *preview* within LyX.

·       WHY this difference?

·       (Could it be that my document is based on LaTeX Book style, while LyX’s 
documentation uses KOMA-script document styles??)

-Bernt L.

From: lyx-users@lists.lyx.org [mailto:lyx-users@lists.lyx.org] On Behalf Of 
Jürgen Lange
Sent: Tuesday, August 9, 2016 18:01
To: lyx-users@lists.lyx.org
Subject: Re: LyX & mhchem package?

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.


Reply via email to