8

I would like to write H2O with a small 2 below the H.

H_2 O (water) 

However, all text after _2 becomes cursive. It appear that something obvious is wrong but, I cant find what it is.

Anyone how have had the same problem?

  • 2
    it is hard to tell, however, the _ needs to be in a math mode to be subscripted. So do H$_2$O. – nickpapior Dec 16 '12 at 20:09
  • 2
    Besides the fact that _ is only valid in math-mode (and LaTeX probably used math-mode from _2 on and didn’t know where to stop), \textsubscript{2} also works mostly. If you find yourself often using chemical formulae you might be interested in certain packages. – Qrrbrbirlbel Dec 16 '12 at 20:11
  • @RollerBoy, you probably (as Gonzalo also indicates) use the mhchem package. It is much inferior in use and can do a lot of stuff! :) – nickpapior Dec 16 '12 at 20:57

1 Answers1

13

Hard to tell without seeing the actual code you are using; anyways, I'd suggest you the mhchem package:

\documentclass{article}
\usepackage{mhchem}

\begin{document}

\ce{H2O}

\end{document}

enter image description here

Another option would be to use the chemmacros package:

\documentclass{article}
\usepackage{chemmacros}

\begin{document}

\ch{H2O}

\end{document}

However, for just one or two formulae, using a package might be overkill, and you could simply say something like

\documentclass{article}

\begin{document}

$\mathrm{H}_2\mathrm{O}$

\end{document}

Or using a command, as cgnieder suggested,

\documentclass{article}
\newcommand*\chem[1]{\ensuremath{\mathrm{#1}}}

\begin{document}

\chem{H_2O}

\end{document}
Gonzalo Medina
  • 505,128