Renewing Latin Phrases in chemmacros does not work

I am trying to redefine a Latin phrase from the chemmacros package. When I try to use \RenewChemLatin{\insitu}{in-situ}, the log prints

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! chemmacros error: "renew-Latin"
!
! You've tried to renew the Latin \insitu , but it doesn't exist.
!
! See the chemmacros documentation for further information.
!
! Type <return> to continue.
!...............................................


When I try to \ProvideChemLatin{\insitu}{in-situ} it tells me:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! chemmacros error: "new-Latin"
!
! You've tried to define a Latin with \NewChemLatin, but the command sequence
!
! See the chemmacros documentation for further information.
!
! Type <return> to continue.
!...............................................


Interestingly I get the same errors when I use \NewDocumentCommand{\insitu}{}{\emph{in-situ}} or \RenewDocumentCommand{\insitu}{}{\emph{in-situ}} repectively.

My MWE:

\documentclass{article}
\usepackage{chemmacros}
\RenewChemLatin{\insitu}{in-situ}
%\ProvideChemLatin{\insitu}{in-situ}
\begin{document}
\insitu
\end{document}


So what am I missing?

• Please, don't use the minimal class, see Why should the minimal class be avoided? – egreg Aug 23 '18 at 9:41
• Alright. I will refrain from using it in the future. I was under the impression, it was adequate for testing purposes, (as said in the answer to your link). – basseur Aug 23 '18 at 13:25

chemmacros only issues

\NewChemLatin \insitu   { in~situ }


in an \AtBeginDocument hook (see chemmacros.module.nomenclature.code.tex, ll. 818-835). That means that \insitu is not defined when chemmacros is loaded, it is defined only at the start of the document.

So when you say

\documentclass{article}
\usepackage{chemmacros}
\RenewChemLatin\insitu{in-situ}
\begin{document}
\insitu
\end{document}


you get an error that you are redefining something that is undefined. And when you use \ProvideChemLatin{\insitu}{in-situ} instead your definition is fine, but the one issued by chemmacros in \AtBeginDocument throws an error, since the command is already defined.

So if you want to redefine \insitu you can use \AtBeginDocument as well. If your call to that hook comes later, it will be executed after the hook from chemmacros.

\documentclass{article}
\usepackage{chemmacros}
\AtBeginDocument{\RenewChemLatin\insitu{in-situ}}
\begin{document}
\insitu
\end{document}


gives

in-situ