Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
2  
it is hard to tell, however, the _ needs to be in a math mode to be subscripted. So do H$_2$O. –  zeroth 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
    
Thanks @zerot $ did the trick! –  RollerBoy Dec 16 '12 at 20:24
    
@RollerBoy, you probably (as Gonzalo also indicates) use the mhchem package. It is much inferior in use and can do a lot of stuff! :) –  zeroth Dec 16 '12 at 20:57

1 Answer 1

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}
share|improve this answer
1  
Similar with chemmacros (\ch{H2O}). The package is probably overkill, though, if one only needs one or two chemical formulas. –  cgnieder Dec 16 '12 at 20:12
    
I not having too much chemical formulas to write so $_2$ will do, but anyway Thanks –  RollerBoy Dec 16 '12 at 20:26
    
@RollerBoy I added another options to my answer; I wouldn't use just $_2$ please see my last example. –  Gonzalo Medina Dec 16 '12 at 20:27
3  
@RollerBoy how about saying \newcommand*\chem[1]{\ensuremath{\mathrm{#1}}} in the preamble and then use it like \chem{H_2O}? –  cgnieder Dec 16 '12 at 20:32
    
@cgnieder I've added your two suggestions to my answer; thank you! –  Gonzalo Medina Dec 16 '12 at 21:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.