4

This question is a follow-up on Siunitx V3 on Overleaf.

I am trying to use version 3 of the siunitx package on Overleaf (TeX Live 2020). After adding the siunitx.sty, as recommended in the previous question, I get compilation errors associated with commands such as

\NewDocumentCommand \DeclareBinaryPrefix { +m m m }

in siunitx. The generated PDF also displays these lines on the top of the page : enter image description here

I created a new Overleaf project, added the siunitx.sty file, and the main.tex file is simply

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

\begin{document}

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

\end{document}

When removing the version 3 file and changing the \qty to \SI to accommodate the version 2 included in TeX Live 2020, everything runs as expected.

1 Answer 1

11

Update

The specific problem that prevented v3.0.22 from compiling nicely with the older TeX Live 2020 on Overleaf was resolved in v3.0.23 (2021-07-26) of siunitx.

The code siunitx loading xparse if it is not yet in the kernel came in a tad too late for some \NewDocumentCommands. See https://github.com/josephwright/siunitx/issues/518.

So grab version v3.0.23 or above from CTAN and you should be fine.


Old answer

There is absolutely no guarantee that this will work, but the primary issue appears to be that \NewDocumentCommand is undefined. That command was recently-ish moved from the xparse package to the LaTeX kernel. In older systems you may have to load \usepackage{xparse}.

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

\begin{document}
This is a test: \qty{5}{\percent}
\end{document}

compiles for me. At least with the siunitx.sty available from .tds.zip from CTAN (http://mirrors.ctan.org/install/macros/latex/contrib/siunitx.tds.zip) (v3.0.22 from 2021-07-22).

See https://www.overleaf.com/read/mwpxvvhrjwvz.

5
  • 2
    siunitx.sty presumably takes this into consideration with: \IfFormatAtLeastTF { 2020-10-01 } { } { \RequirePackage { xparse } }. This doesn't mean I know why it fails for the OP and your MWE works... Does "recently-ish" means later than "2020-10-01"?
    – gusbrs
    Jul 25, 2021 at 16:32
  • 2
    @gusbrs Oh, so it does. But too late (l. 7333) for some \NewDocumentCommands (e.g. ll. 7090, 7094) in the .sty. Reported at github.com/josephwright/siunitx/issues/518.
    – moewe
    Jul 26, 2021 at 5:02
  • And yes, xparse was added to the kernel in the October 2020 release.
    – moewe
    Jul 26, 2021 at 5:08
  • Ah, great! That clears things up. And thanks for reporting!
    – gusbrs
    Jul 26, 2021 at 12:33
  • Updated on CTAN. Version 3.0.23 solves the problem. Thanks for reporting!
    – Zork
    Jul 28, 2021 at 12:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .