9

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{ver@amsmath.sty}{}
\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{ver@amsmath.sty}{}
\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 !

  • Welcome to TeX.sx. \@namedef{ver@amsmath.sty}{} lets every following package think that amsmath had been loaded which in this case prevents mhchem from loading it. Unfortunately for you mhchem needs amsmath – clemens Jul 15 '15 at 14:21
  • 2
    The workaround should work with chemformula, though. – clemens Jul 15 '15 at 14:38
  • Thanks all @clemens : I tried the same with chemformula (\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 ? – fmollica Jul 15 '15 at 16:34
  • it won't work with chemmacros which is why I suggested chemformula – clemens Jul 15 '15 at 16:44
  • 2
    chemformula has another syntax than mhchem! You have to explicitly switch to mathmode. Use \ch{P ->[$\sigma_{P}$] T} or \ch{P ->[$\sigma$ _{P} ] T} depending on the meaning of the P. (BTW: instead of editing this question it would have been better to ask a new question since this is unrelated to the original issue) – clemens Jul 16 '15 at 8:36
11

Form the file ioplatexguidelines.pdf:

enter image description here

Since mhchem loads and, more importantly, requires amsmath, you have two options: stick to iopart.cls and don't use mhchem but another package offering a similar functionality, or change your document class and use mhchem; as the guideline mentions this is not a problem since they will accept your document written using any other document class.

  • 5
    And the reason why iopart doesn't want amsmath just to use their badly defined environments is very obscure. – egreg Jul 15 '15 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.