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 denote a molecular ion using the chemcompounds package. This would involve wrapping part of a chemcompounds descriptor in square brackets, like so:

$[1]^{2+}$

However, because the chemcompounds name argument is placed between square brackets, trying to do this causes an error.

How is it done?

MWE

\documentclass[a4paper]{minimal}
\usepackage{chemcompounds}
\declarecompound[J]{c1}
\declarecompound[J$^{+}$]{c1c}
%\declarecompound[[J]$^{+}$]{c1bc}

\begin{document}

This species is denoted \compound{c1}.

This molecular ion is denoted \compound{c1c}.

%This molecular ion breaks chemcompounds: \compound{c1bc}.

\end{document}

(I have commented out the lines that break compilation)

share|improve this question
1  
It is always best to compose a MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. –  Peter Grill Nov 8 '11 at 2:42
add comment

1 Answer

up vote 5 down vote accepted

Normally, an extra pair of braces solves this kind of problem:

\documentclass{article}
\usepackage{chemcompounds}

\declarecompound[${[1]^{2+}}$]{label}

\begin{document}

\compound{label}

\end{document}

enter image description here

If this was not the case, while you provide a proper MWE with chemcompounds, I would suggest you to use the mhchem package instead:

\documentclass{article}
\usepackage{mhchem}

\begin{document}

\ce{$[1]^{2+}$}

\end{document}

enter image description here

share|improve this answer
    
The extra braces fix the problem, thanks. I already use mhchem for formulae, but chemcompounds serves a different role, namely the consistent abbreviation of compounds. –  Richard Terrett Nov 8 '11 at 3:15
add comment

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.