[Tex/LaTex] Undefined control sequence with mhchem

mhchem

Using pdflatex [Version 3.14159265-2.6-1.40.16 (MiKTeX 2.9 64-bit)] to compile the following:

\documentclass{article}
\usepackage[version=4]{mhchem}
\begin{document}
Hello, world!
\end{document}

throws the following error:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "kernel/command-not-defined"
! 
! Control sequence \str_case:nnn undefined.
! 
! See the LaTeX3 documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.58 \cs_generate_variant:Nn \str_case:nnn { Vnn }

Note that I am using mhchem v4.01.

Any help in regards to fixing this issue is appreciated.

Best Answer

Joseph Wright wrote a message to 10 package authors last weekend (and I am sure he does not mind quoting it here).

Hello all,

I've done a recent expl3 update in which I've remove functions deprecated in 2013, following the pattern we've set up. A sweep of TeX Live shows there are a few stray uses of \int_case:nnn, \tl_case:Nnn, \str_case:nnn and \str_case_x:nnn, all of which should now end "F" (e.g. \str_case:nnF). These are easy to miss (I've got one myself to fix in siunitx), but updates of your code to match expl3 would be welcome.

Where I can I've made pull requests on GitHub/BitBucket with fixes. I've also asked that TL don't update the expl3 version until people have a chance to address this.

Regards,

Joseph

So, MikTeX updated too quickly. Less than a week seems not enough for 10 package authors to update their packages.

Update: I updated mhchem. The upload to CTAN was made 2015-07-23. It will take a day to get approved, a day to distribute to the mirrors and a few extra days until you will eventually see it as a MiKTeX update.

This addendum might be useful for others, but is not related to the mhchem package: After correcting the signature (from :nnn to :nnF), the functions were renamed once again to correct the type of expansion they perform. \str_case_x:nn(TF) is now \str_case_e:nn(TF) (the x expansion is slightly different from the e expansion, and the latter is correct for these functions).