Chemistry Equations

I have the following Chemistry equation:

2LiOH(s) + CO2(g) -> Li2CO3(s) + H2O

And I have the following LaTeX code:

\ce{2LiOH_{(s)} + CO_{2(g)} -> Li_{2}CO_{3(s)}+ H_{2}O_{(g)}}


But I can't get it to render properly. It displays like this:

Look at the arrow. What other parameters do I need?

-
Just a sidenote: IUPAC recommends to typeset “the states of aggregation of chemical species [...] appended to the formula in parentheses and [...] printed in Roman (upright) type without a full stop (period).” This means: not as a subscript. –  clemens Mar 26 '12 at 16:09

Can you please post a MWE? I can't reproduce your problem; the following simple code

\documentclass{article}
\usepackage{mhchem}

\begin{document}
\ce{2LiOH_{(s)} + CO_{2(g)} -> Li_{2}CO_{3(s)} + H_{2}O_{(g)}}
\end{document}


gives me:

Perhaps you are using some outdated package(s)?

-
Whats a MWE? I will post one if i knew what it is. –  Dean Mar 21 '11 at 20:50
Yes i was using chemstyle so i changed to the mhchem one and thats fixed the problem thanks. –  Dean Mar 21 '11 at 20:52
@Dean: MWE = minimal working example. I initially forgot the link but now it's added. –  Gonzalo Medina Mar 21 '11 at 20:54
@Dean, Gonzalo: See also the post on meta about minimal examples. It also links to the page in Gonzalo's answer. –  Martin Scharrer Mar 21 '11 at 20:58
Note that there should be a space before the + on the right-hand side, or the package interprets the + to indicate an ion. –  alex.jordan Mar 22 '13 at 22:07

The {mhchem} package is sensitive to spaces and I think the problem you were having was just due to some spaces in the wrong places. Compare:

\ce{2LiOH_{(s)} + CO_{2(g)} - >Li_{2}CO_{3(s)}+ H_{2}O_{(g)}}

\ce{2LiOH_{(s)} + CO_{2(g)} -> Li_{2}CO_{3(s)} +H_{2}O_{(g)}}

Also it is worth noting that in this package numbers in chemical formulas are assumed to be subscripts, this saves some typing

\ce{2LiOH_{(s)} +CO2_{(g)} -> Li2CO3_{(s)} +H2O_{(g)}}

-

You could use \rightarrow instead of ->, if that doesn't work.

\ce{2LiOH_{(s)} + CO_{2(g)} {\rightarrow} Li_{2}CO_{3(s)}+ H_{2}O_{(g)}}


Since you are writing chemistry, you might be interested in the command \chemarrow provided by the chemarrow package.

-
or maybe \to. –  Martin Scharrer Mar 21 '11 at 20:50
There are a lot of arrows :-) interesting here is that they it should be enclosed within braces to not harm the rest of the equation. –  Stefan Kottwitz Mar 21 '11 at 20:55
@Martin: but isn't \to just another name for \rightarrow? –  Gonzalo Medina Mar 21 '11 at 21:08
@Gonzalo: Indeed it is! I didn't know that before. I would prefer it because it is 1) shorter and 2) more logical in this case, because the left side is transformed to the right side :-) –  Martin Scharrer Mar 21 '11 at 21:11