13

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 !

10
  • Welcome to TeX.sx. \@namedef{[email protected]}{} 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
    – cgnieder
    Jul 15, 2015 at 14:21
  • 2
    The workaround should work with chemformula, though.
    – cgnieder
    Jul 15, 2015 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, 2015 at 16:34
  • it won't work with chemmacros which is why I suggested chemformula
    – cgnieder
    Jul 15, 2015 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)
    – cgnieder
    Jul 16, 2015 at 8:36

3 Answers 3

13

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.

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

The two approaches below woks for me. They are really a huge help.

(1)

\expandafter\let\csname equation*\endcsname\relax

\expandafter\let\csname endequation*\endcsname\relax

Put these just before \usepackage{amsmath}

(2)

Alternatively, edit iopart.cls and remove (or comment) these two lines (lines 788 and 789 in my copy):

\@namedef{equation*}{\[}

\@namedef{endequation*}{\]}

originally from

https://groups.google.com/g/comp.text.tex/c/mgzSLY8zCa8

2

I recently across the same problem between iopart and amsmath. The warning I saw was "Command \equation* already defined." I fixed it by commenting out these two lines:

\@namedef{equation*}{\[}
\@namedef{endequation*}{\]}

in iopart.cls (lines 788-789 for me). It seems that they want

\begin{equation*}
F=ma
\end{equation*}

to be just

\[F=ma\]

for some reason which is kind of stupid. I don't think commenting these lines out will break anything else, but I'm not sure.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .