Math & Sciencemhchem package

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

mhchem package

Post by svend_tveskaeg »

Hi all.

Consider the following example, which compiles just fine:

Code: Select all

\documentclass{article}
\usepackage[version=3]{mhchem}

\begin{document}

\begin{equation}
  \ce{CH3\sbond (CH2)_{n}\sbond COOH}
\end{equation}

\end{document}
I would like the subscript n to be in mathmode but when I write

Code: Select all

\ce{CH3\sbond (CH2)_{$n$}\sbond COOH}
($'s around the n, that is) I get the following error:

Code: Select all

! Missing } inserted.
<inserted text> 
                }
l.7   \ce{CH3\sbond (CH2)_{$n$}\sbond COOH}
I really do not understand why.

Can someone tell me how to get the n in mathmode? (Here is the mhchem manual.)


Furthermore, the space between `)' and 'n' seems (a least to me) to be too big. How do I correct this?


Thank you in advance!
Last edited by svend_tveskaeg on Thu Dec 16, 2010 5:15 pm, edited 2 times in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

mhchem package

Post by localghost »

svend_tveskaeg wrote:[…] I really do not understand why. […]
Neither do I.
svend_tveskaeg wrote:[…] Can someone tell me how to get the n in mathmode? […]
You can use an italicized »n«. Math mode uses nothing else.
svend_tveskaeg wrote:[…] Furthermore, the space between `)' and 'n' seems (a least to me) to be too big. How do I correct this? […]
I'm not aware of an automatism. It seems that you have to correct this manually.

Code: Select all

\documentclass{article}
\usepackage[version=3]{mhchem}

\begin{document}
  \begin{equation}
    \ce{CH3\sbond (CH2)_{\!\emph{n}}\sbond COOH}
  \end{equation}
\end{document}

Thorsten
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

mhchem package

Post by svend_tveskaeg »

Thanks you for your help!

I came up with the solution following:

Code: Select all

\begin{equation}
  \ce{CH3\sbond (CH2)_{\hspace{-2pt}\text{$n$}}\sbond COOH}
\end{equation}
Not a pretty solution but it works. (I only have to use a mathmode subscript once in the document.)
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply