3

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
! \insitu  already exists. Please choose another name.
! 
! 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?

basseur
  • 912

1 Answers1

4

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

moewe
  • 175,683