# Conflict between siunitx and hyperxmp?

When I typset this MWE:

% arara: lualatex: {synctex: yes, shell: yes}
\documentclass[%
fontsize=10pt, %
twoside,%
DIV=calc, %
a4paper]{scrartcl}

\usepackage{mathtools}

\usepackage[free-standing-units=true,overwrite-functions=true]{siunitx}

\usepackage{hyperxmp}

\usepackage{hyperref}
%
\begin{document}

s_{ij} =\int_a^b {s_i \left( t \right) \phi _j ^{\ast} \left( t \right)dt},\quad \begin{aligned} i&=1,\ldots, M\\ j&=1,\ldots, N \end{aligned}

\end{document}


there is an error in the second run. The error doesn't exist if I don't load the hyperxmp package. Any help? Thanks in advance

• When you use free-standing-units=true, siunitx will redefine the TeX primitive \day to the SI unit for day. The hyperxmp package (and many others, actually) expects that \day is the TeX primitive, not something else, thus the error. And that's why siunitx defines the units only inside its own commands, so that this type of conflict doesn't happen. If you remove free-standing-units=true the error will go away. – Phelype Oleinik Sep 3 '19 at 14:18
• @Phelype Oleinik: Perfect! Can you put your solution in an answer? In this way, I could vote up. Thanks – jpayansomet Sep 3 '19 at 14:22

The hyperxmp package inserts some code at \end{document} that does \ifnum\day<10 <do things>\fi, which expects \day to be a number. \day is a TeX primitive register which holds the number of the current day, so everything's fine so far.
However, when you use free-standing-units=true and overwrite-functions=true (a dangerous combination), siunitx will redefine the TeX primitive \day to the SI unit for day. But the hyperxmp package (and many others, actually) expects that \day is the TeX primitive, not something else. And when it does \ifnum\day<10 it finds something that is not a number and TeX says Missing number, treated as zero. And that's why siunitx defines the units only inside its own commands, so that this type of conflict doesn't happen.
If you remove free-standing-units=true the error will go away. Alternatively you can set overwrite-functions=false, so that the only functions siunitx will define "free-standing" are the ones whose names are not yet taken, so \day will remain being TeX's \day, while \metre, for example, will be siunitx's.