0

Consider the following MWE where the code comes from here and is then modified a bit:

\documentclass{article}

\usepackage{siunitx}

\ExplSyntaxOn \NewDocumentCommand\SIexpr{O{,}mm}{ \SIext:nnn{#1}{#2}{#3} }

\cs_new_protected:Npn \SIext:nnn#1#2#3{ \seq_set_split:Nnn \l_SIext_input_seq{#1}{#2} \seq_pop_left:NN \l_SIext_input_seq \l_SIext_first_tl \seq_clear:N \l_SIext_output_seq \seq_put_right:Nx \l_SIext_output_seq{ \fp_compare:nTF{\l_SIext_first_tl > 0} {\num{\l_SIext_first_tl}} {-\num{\tl_tail:V \l_SIext_first_tl}} } \seq_map_inline:Nn \l_SIext_input_seq{ \seq_put_right:Nx \l_SIext_output_seq{ \fp_compare:nTF{##1 > 0} {+\num{##1}} {-\num{\tl_tail:n{##1}}} } }

\SI[ parse-numbers = false, quotient-mode = fraction, input-product = *, output-product = \cdot ]{ \sisetup{parse-numbers} \left(\seq_use:Nn \l_SIext_output_seq{}\right) }{#3} } \ExplSyntaxOff

\begin{document}

\SIexpr{5, -2*1}{\s}

\end{document}

Whan I compile via pdflatex using my up-to-date TeX Live 2021 distribuion, I get the following warning and error:

Package siunitx Warning: Option "quotient-mode" has been removed in this
(siunitx)                release.

! LaTeX3 Error: The key 'siunitx/input-product' is unknown and is being (LaTeX3) ignored.

For immediate help type H <return>. ...

l.41 \SIexpr{5, -2*1}{\s}

How do I fix the code in order for it to compile properly once again?

  • Have you looked at https://tex.stackexchange.com/questions/598236/siunitx-3-quotient-mode-has-been-removed-in-this-release : – jotagah May 26 '21 at 03:49
  • the answer you linked too didn't use input-product and in combination with parse-numbers = false it looks a bit odd there. In any case if you want products, you will have to check the documentation for \numproduct and \qtyproduct. Also I don't think that you can use *, you will have to use x for the product. – Ulrike Fischer May 26 '21 at 07:32
  • The code in my answer works with the new release of siunitx. – egreg May 26 '21 at 08:45
  • @egreg Thank you, Enrico! Assume that I have defined, say, \def\horse{45}. Then I cannot use \SIexpr{200, -2*\horse}, but I have to put 2*\horse inside an \fpeval{}. Can this be changed so that I don't have to use \fpeval{}? – Svend Tveskæg May 26 '21 at 14:25
  • I'm not sure what's the expected output. – egreg May 26 '21 at 14:44
  • @egreg It should be 110 (= 200 - 2*45) in this case. I have this issue in quite a few documents so it would help me alot if this can be "fixed". (I think the problem is that input-product isn't suppoered anymore but I'm not sure.) – Svend Tveskæg May 26 '21 at 18:40

0 Answers0