LyXLyx processor: mhchem package does not format the text

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
Sprn
Posts: 4
Joined: Thu Mar 10, 2016 5:37 pm

Lyx processor: mhchem package does not format the text

Post by Sprn »

I have a problem with writing chemical equations in LyX by using mhchem package. The package is working fine with LaTeX, for example in TexMaker that I have installed. However, in LyX mhchem does not format formulas at all: no superscripts, no subscripts, no arrows etc.

For example, \ce{H2O -> H2 + 1/2 O2} normally should give me nicely formatted equation of water decomposition. In LyX that I have it returns the text between parenthesis unformatted. And in LaTeX it is working without any problems.

I have LyX version 2.1.4 under UberStudent Linux (Ubuntu-based distribution with XFCE desktop).

Thanks for any hints or help!
Last edited by cgnieder on Wed Mar 16, 2016 11:23 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Re: Lyx processor: mhchem package does not format the text

Post by scottkosty »

Is the output PDF from LyX as you expect?

Note that one of LyX's main developers is a chemist and uses mhchem a lot, so I imagine there is a way to get it working as you desire.

I just took a look and if I go to Help > Math, and then I read the part discussing mhchem, indeed \ce{H2CO3} is shown in LyX as H2CO3 but if I select the inset and go to Insert > Preview, then it shows it with the subscripts.
Sprn
Posts: 4
Joined: Thu Mar 10, 2016 5:37 pm

Re: Lyx processor: mhchem package does not format the text

Post by Sprn »

Thanks for the reply.

No, unfortunately there are no subscripts neither in instant preview, nor in generated pdf (export by pdflatex).

If this is not a general problem in LyX, can it be the problem of Lyx installed in my system? If yes, what is the safest way to re-install Lyx in Ubuntu-based distribution?
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Lyx processor: mhchem package does not format the text

Post by scottkosty »

Sprn wrote:Thanks for the reply.

No, unfortunately there are no subscripts neither in instant preview, nor in generated pdf (export by pdflatex).

If this is not a general problem in LyX, can it be the problem of Lyx installed in my system? If yes, what is the safest way to re-install Lyx in Ubuntu-based distribution?
The best way to figure this is out is for you to upload a minimal example that I can try and see if it works for me. Since you are using Ubuntu, I'll be able to give you directions for how to fix something if it comes to it.
Sprn
Posts: 4
Joined: Thu Mar 10, 2016 5:37 pm

Re: Lyx processor: mhchem package does not format the text

Post by Sprn »

Thank you for the reply.
I uploaded lyx file and generated pdf file. In pdf no formating when I am using mhchem is kept, so all chemical formulas are not formatted.
Attachments
extract_test.pdf
(74.61 KiB) Downloaded 226 times
extract_test.lyx
lyx-file
(4.1 KiB) Downloaded 269 times
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Lyx processor: mhchem package does not format the text

Post by Johannes_B »

You have an extra pair of braces there, get rid of them.
Have a look at package siunitx, you µ should be upright, not italic.


Look what strange code you generated. I guess this comes from clicking on too many buttons, i would use ERT-boxes instead.
Compare the output of the two separated lines by clicking on open iin writelatex.

Code: Select all

%% LyX 2.0.8.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\PassOptionsToPackage{version=3}{mhchem}
\usepackage{mhchem}
\usepackage{siunitx}
\usepackage{babel}
\begin{document}

\section{03/03/2016 : GK-Supercaps, pH-effect}


\subsection*{Motivation: }

to test the idea of increasing the cyclability by adjusting pH. Solubility
of the products of $\ce{{MnO-Mn3O4-Mn2O3-MnO2}}$ transitions increases
as pH increasing \cite{Chouaib1981}. So, the tests at different pH
down from the conventional pH=14 (1M NaOH) are planned.


\subsection*{Preparation :}


\subsubsection*{Catalyst:}

The powder was prepapred by GK last year. It was utilized in a numerous
experiments last year (see experiments from 31/07/2015 to 02/10/2015). 


\subsubsection*{Electrode:}

Generally, all electrodes are prepared to have 47 $\mathrm{{\mu g/cm^{2}}}$
of oxide per geometric surface area of GC support. The latter is 0.071
$\mathrm{{cm^{2}}}$, which makes 3.37 $\mathrm{{\mu g}}$ of oxide

in the deposit, or, for \SI{34}{\percent} \ce{Mn3O4}-Vulcan-ISAC,% taht would be better

in the deposit, or, for 34\% $\ce{\mathrm{\ce{{Mn3O4}}}}$-Vulcan-ISAC,

9.81 $\mathrm{{\mu g}}$ of the catalyst. The deposition is done from
0.3 mg(oxide)/ml($\ce{{H2O}}$) suspension, thus one needs to deposit
11.23 $\mathrm{{\mu l}}$ of the ink. It is done in 3 steps, with
3.74 $\mathrm{{\mu l}}$ of ink deposited each step. The drop is dried
under $\mathrm{{N_{2}}}$ flow, ca. 10-15 min. After the last step,
a quote of the solution of ionomer (Fukuyama), 2 $\mathrm{{\mu l}}$
is deposited for the layer stability. 


\subsubsection*{Electrolyte:}

0.1 M NaOH, 250 ml;

RE is always in 1 M NaOH


\subsubsection*{Results and discussion:}


\paragraph*{1. \label{par:1.-First-CV}First CV cycling to stabilize the sample,
15 cycles, 20 mV/s; }

limits:

1 M NaOH, $\mathrm{{pH}\approx14}$, -0.50 .. 0.30 V MMO

0.1 M NaOH, $\mathrm{{pH}\approx13}$, -0.44 .. 0.36 V MMO
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Sprn
Posts: 4
Joined: Thu Mar 10, 2016 5:37 pm

Re: Lyx processor: mhchem package does not format the text

Post by Sprn »

Yes, great, it worked!

Indeed, I was typing: Ctrl-M, \ce{ ... - and this gave always extra pair of braces.

Thank you, problem seem to be solved.
Post Reply