# Maths symbols and unicode-math input inside siunitx commands

What I’m trying to do is to input Unicode characters directly inside siunitx commands, like \SIrange{≳9}{≈40}{\kilogram}. But it does not work and I get errors like ! Package siunitx Error: Invalid token '≳' in numerical input..

Looking further, inputing the standard command for these symbols does not work for all of them either: \SIrange{\gtrsim9}{\approx40}{\kilogram}; \gtrsim breaks but \approx is accepted.

Some MNWE:

\documentclass{standalone}

\usepackage{siunitx}
\usepackage{unicode-math}

\begin{document}
\SIrange{≳9}{≈40}{\kilogram}\\
\SIrange{\gtrsim9}{\approx40}{\kilogram}
\end{document}


Does what I’m trying to do makes any sense? Is there a way to do that?

• I think the parser needs to know those in advance to support them. It does not handle all symbols by default only common ones. The ones you present here are not really common Mar 17, 2019 at 18:11

You can add other comparators to the default list:

\documentclass{article}

\usepackage{siunitx}
\usepackage{unicode-math}

\sisetup{
input-comparators = {
< = > \approx \ge \geq \gg \le \leq \ll \sim % default
\gtrsim ≳ ≈
},
}

\begin{document}

\SIrange{≳9}{≈40}{\kilogram}

\SIrange{\gtrsim9}{\approx40}{\kilogram}

\end{document}


• Awesome, thanks. I guess there are reasons for the initial list being limited to those symbols? Like symbols origins (TeX/LaTeX/amssymb…) for the others or something in that vein? Mar 18, 2019 at 15:11
• @ArchangeThe author added the most common comparators, I guess. Mar 18, 2019 at 15:32

You could set parse-numbers to false to allow arbitrary code in the number fields:

\documentclass{standalone}

\usepackage{siunitx}
\usepackage{unicode-math}

\begin{document}
\SIrange[parse-numbers = false]{≳9}{≈40}{\kilogram}\\
\SIrange[parse-numbers = false]{\gtrsim9}{\approx40}{\kilogram}
\end{document}


Or, you could declare the symbols explicitly in \sisetup:

\documentclass{standalone}

\usepackage{siunitx}
\sisetup{
input-symbols=≈≳\gtrsim\approx
}
\usepackage{unicode-math}

\begin{document}
\SIrange{≳9}{≈40}{\kilogram}\\
\SIrange{\gtrsim9}{\approx40}{\kilogram}
\end{document}

• parse-numbers=false has side effects I would prefer to avoid. input-symbols is good, but input-comparators from @egreg has even better semantical value. ;) Mar 18, 2019 at 15:14