I know how to write a usual index with the help of the underscore, but I seem to be unable to find out how to write an (upper/lower) index in front of a letter/text.
These kind of indices are common in chemistry.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI know how to write a usual index with the help of the underscore, but I seem to be unable to find out how to write an (upper/lower) index in front of a letter/text.
These kind of indices are common in chemistry.
You have to supply a "fake" object for TeX to put indices to:
${}^1_2X^3_4$
However, for chemistry typesetting you should use one of the specialized packages, such as mhchem
. This example is taken from mhchem
documentation:
\ce{^{227}_{90}Th+}
It will typeset the symbol for a positive Thorium ion with a charge of 90 and atomic mass of 227.
mathtools
provides among other useful things the prescript
command for this. Verbose, but useful if you don't want to fiddle with negative spaces and fake objects.
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
{}^{4}_{12}\mathbf{C}^{5+}_{2}
\quad
\prescript{14}{2}{\mathbf{C}}^{5+}_{2}
\quad
\prescript{4}{12}{\mathbf{C}}^{5+}_{2}
\quad
\prescript{14}{}{\mathbf{C}}^{5+}_{2}
\quad
\prescript{}{2}{\mathbf{C}}^{5+}_{2}
\]
\end{document}
The easiest in this case would be to use the leftidx
package. Taken directly from the package documentation:
\usepackage{leftidx}% http://ctan.org/pkg/leftidx
...
$\leftidx{_1^2}{\left(\frac{1}{b}\right)}{_3^4}$
The package offers the command \leftidx{<left indices>}{<stuff>}{<right indices>}
.
I just saw this package a few minutes ago and it has a good example of this. There are probably other packages for Chemistry usage though.
\documentclass{article}
\usepackage{amsmath}
\usepackage{tensor}
\begin{document}
$\tensor*[^{14}_6]{\mathrm{C}}{}$
\end{document}
This example is directly copied form the tensor package.
mhchem
package helps.