TransWikia.com

Command already defined - IOP publication with mhchem

TeX - LaTeX Asked by fmollica on August 13, 2021

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 #2color@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 !

2 Answers

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.

Correct answer by Gonzalo Medina on August 13, 2021

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

(1)

expandafterletcsname equation*endcsnamerelax

expandafterletcsname endequation*endcsnamerelax

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

Answered by youfan on August 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP