Possible Duplicate:
Cursive text after _

I need to have some subscripted and superscripted text in my thesis document. But when I try to do it the way as H_{2O} or S^{2}. I get an error at that point and if I compile it anyway I get text with so white spaces for the rest of the line. Like,


Do I need to use some package to have this functionality? I thought it was standard latex. Or may be it is due to conflict with some package. I'm using the university template so don't quite understand what the problem is. I have put the header section where the packages are called below. Please help.


4 Answers 4


If you are typesetting chemical formula, look up the mhchem package. This allows you to typeset chemical formulae easily.

For example: \ce{CO2} has the "2" as a subscript. Neat.




  • +1 For chemical formula this is the way to go (Sorry Seamus, I'm already out of votes for today). My answer was more about the general case. Feb 18, 2011 at 15:28
  • 1
    One could also use the package chemmacros and its command \ch (not that there's anything wrong with mhchem :) )
    – cgnieder
    Sep 30, 2012 at 9:03
  • 1
    The chemmacros package looks a lot more powerful than mhchem, but for what was required for this question, I think mhchem is the simpler, smaller, cheaper option.
    – Seamus
    Oct 1, 2012 at 10:40

The _ and ^ character only work in math-mode. For text you need to use \textsubscript (needs the fixltx2e package) and \textsuperscript instead.

The reason why all the whitespace after H_{2O} is missing is that TeX changing into math-mode at the _ and then all the letters afterwards are set as variables. Also I think you mean H_{2}O (BTW: the braces can be skipped when they include only one character).


No special package but you need to be in math-mode. Use $ $ or \ensuremath{}.

  • 6
    This is not a good solution. You shouldn't use mathmode for things that aren't maths. There is a textsubscript option mentioned in a different answer that is the Right Way to do this...
    – Seamus
    Feb 18, 2011 at 15:18
  • 2
    @Seamus: is this the reason, why you never use footnotes ;-)
    – user2478
    Feb 18, 2011 at 16:12
  • @Herbert Is that how footnotes work? Huh. I am going to start boycotting footnotes now! But seriously, since footnotes are marked up "semantically" it's ok, even if they abuse mathmode internally...
    – Seamus
    Feb 21, 2011 at 12:36

The easiest ways I have found to include super- and subscripts in text mode are shown below. The example is the chemical formula for silicon dioxide:

Method 1:

$\rm SiO_2$

Method 2:


I am using MikTeX 2.4 and dvips + ps2pdf, and my PDF output looks good: The letters are definitely in text mode, not math, and the results of the two methods look the same in PDF.

An addendum: If the super- or subscript is an expression, do the following:


which yields the chemical formula for polyethylene.


Not the answer you're looking for? Browse other questions tagged .