I am using iopart
class for IOP publication, and I want use the mhchem
package for writing chemical equations. I ran into the same problem as here and there, old topics without answer. I compile with pdflatex in Texmaker the following code:
\documentclass[12pt]{iopart}
%Uncomment next line if AMS fonts required
%\usepackage{iopams}
\usepackage[version=3]{mhchem}
\begin{document}
\title[mytitle]{mytitle}
\author{myauthor}
\begin{abstract}
A minimal non-working iopart + mhchem example
\end{abstract}
\ce{P ->[\sigma_{P}] T}
\end{document}
This throws back the error
! LaTeX Error: Command \equation* already defined.
Or name \end... illegal, see p.192 of the manual.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.2664 }
I added the advice in here:
\makeatletter
\@namedef{[email protected]}{}
\makeatother
\usepackage{amstext}
before \usepackage[version=3]{mhchem}
. I have no clue what it means.
But it raises plenty of errors :
! Undefined control sequence.
<argument> \rightarrowfill@
\displaystyle
l.18 \ce{P ->[\sigma_{P}] T}
?
! Missing $ inserted.
<inserted text>
$
l.18 \ce{P ->[\sigma_{P}] T}
?
! Extra }, or forgotten $.
\@begin@tempboxa ...begingroup #2\color@endgroup }
\def \width {\wd \@tempbox...
l.18 \ce{P ->[\sigma_{P}] T}
?
! Missing $ inserted.
<inserted text>
$
l.18 \ce{P ->[\sigma_{P}] T}
?
! Missing } inserted.
<inserted text>
}
l.18 \ce{P ->[\sigma_{P}] T}
EDIT: Following comments below I tried :
\documentclass[12pt]{iopart}
%Uncomment next line if AMS fonts required
%\usepackage{iopams}
\makeatletter
\@namedef{[email protected]}{}
\makeatother
\usepackage{amstext}
\usepackage{chemformula}
\begin{document}
\title[mytitle]{mytitle}
\author{myauthor}
\begin{abstract}
A minimal working iopart + chemformula example
\end{abstract}
\ch{P ->[$\sigma$] T} \par
\end{document}
And it does the job !
\@namedef{[email protected]}{}
lets every following package think thatamsmath
had been loaded which in this case preventsmhchem
from loading it. Unfortunately for youmhchem
needsamsmath
…chemformula
, though.(\usepackage{chemmacros})
. with the \@namedef workaround. It throws error on mathtools.sty :! LaTeX Error: Environment gathered undefined.
and! LaTeX Error: \aligned@a undefined.
. chemformula use packages l3kernel[The13a], xparse, l3keys2e and xfrac said the user's guide. Maybe I should force it to load only those, instead of bundle ? But how ?chemmacros
which is why I suggestedchemformula
chemformula
has another syntax thanmhchem
! You have to explicitly switch to mathmode. Use\ch{P ->[$\sigma_{P}$] T}
or\ch{P ->[$\sigma$ _{P} ] T}
depending on the meaning of theP
. (BTW: instead of editing this question it would have been better to ask a new question since this is unrelated to the original issue)