1

I've recently started to use LyX with mhchem to typeset chemical formula, and everything works fine when using pdflatex from the command line, but for some reason LyX will throw an error about a bad control sequence in expl3-code.tex. Interestingly, it's still rendered fine if I press "Show Output Anyway".

I thought I might have had a bad MacTeX installation so I reinstalled it and I noticed that mhchem and LyX then behaved fine. The issue only comes up after updating all packages to the latest version in TeX Live. I assume it might be a backwards incompatible change in expl3.

mhchem: v4.08
l3kernal: Release 2019-09-05 LyX: 2.3.3 (I might have initially tried this with a git build, same thing)
pdflatex: 3.14159265-2.6-1.40.20 (TeX Live 2019)
macOS 10.14.6

Minimal erroring example (note that it renders fine, but still gives an error during compilation)

\makeatletter
\def\input@path{{/Users/perry/Documents/}} % Inserted by LyX, necessary for the error
\makeatother
\documentclass{article}
\usepackage[version=4]{mhchem}

\begin{document}
$\ce{Hi}$
\end{document}
(/usr/local/texlive/2019/texmf-dist/tex/latex/mhchem/mhchem.sty
Package: mhchem 2018/06/22 v4.08 for typesetting chemical formulae
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2019-09-05 L3 programming layer (loader) 
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3-code.tex
Package: expl3 2019-09-05 L3 programming layer (code)
\c_max_int=\count100
[...]
\l__seq_internal_b_int=\count186
! Undefined control sequence.
<argument> \__kernel_file_name_quote:e 
                                       {\tl_to_str:n {/Users/perry/Documents...
l.27981   }

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

)

I'm new to TeXExchange™, so please let me know if I need to provide some more details.

2

This was due to a missing :e variant of the \__kernel_file_name_quote:n function in the LaTeX3 kernel.

The same error is reported here and it was recently fixed in this commit. The updated code is already on CTAN, so if you update the l3kernel package the error should go away.

|improve this answer|||||
  • 3
    \ExplSyntaxOn\cs_generate_variant:Nn\__kernel_file_name_quote:n{e}\ExplSyntaxOff is way better – egreg Sep 10 '19 at 17:28
  • @egreg I completely agree. However the error happens while loading expl3, so it needs to be defined earlier... – Phelype Oleinik Sep 10 '19 at 17:29
  • I see: that's for the pesky \input@path before \documentclass. LyX… :-( – egreg Sep 10 '19 at 17:33
  • @egreg Yes :/ I think that loading expl3 and defining the variant with your suggestion before the \input@path thingy would also work, but I don't know if LyX allows that. Anyhow, I'll remove the code once the update gets to CTAN so that people won't be tempted to use it ;-) – Phelype Oleinik Sep 10 '19 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.