Siunitx 3 and amsmath : compilation time out on Overleaf with TeX Live 2020

amsmathnicematrixoverleafsiunitx

When using version 3.0.23 of siunitx on Overleaf with TeX Live 2020, I get compilation time out when running the code

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{siunitx}

\begin{document}

This is a test : \qty{5}{\percent}

\end{document}

Changing the order of the package loading doesn't change the end result.

Removing amsmath allows the file to compile normally, and so is reverting to siunitx 2.8 included in TeX Live 2020 on Overleaf while keeping amsmath. Also, in the packages I use daily, only nicematrix has the same time out problem, but it has amsmath as a required package.

Any chance someone here encountered that problem before?

Thanks in advance.

Best Answer

This is caused by a non-robust definition of \, with older set-ups, which means that there is an internal error when trying to expand and replace \, (needed internally for input-ignore). The easiest work-around it to make \, robust, for example

\usepackage{etoolbox}
\robustify\,

before loading siunitx v3.

Related Question