21

With the upgrade to version 3.0.0 of siunitx it is no longer possible to use fractions in units.

Consider this minimal example:

\documentclass{article}
\usepackage{siunitx}
\sisetup{
    quotient-mode = fraction,
}
\begin{document}
\num{7 / 2}
\end{document}

This is the output:

[...]

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

[...]

! Package siunitx Error: Invalid number '7 / 2'.

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

l.7 \num{7 / 2}

In version 2 it would generate a document with a fraction 7 / 2.

The documentation only gives the following hint, but I am not sure how to interpret it.

  • Quotients of numbers are only supported as literals;

What can I do to obtain the old behaviour? Should I skip siunitx entirely and just write $\frac{7}{2}$? This would ignore any siunitx setting, but for all I know they were also ignored in previous versions for fractions.

Claudio
  • 2,007

1 Answers1

16

This is a by-design change, and one reason for the major version step. Fractions really do not fit in with the entire idea of parsing numbers into parts, and I've tried hard to tighten up the details here. You'll need

\documentclass{article}
\usepackage{siunitx}
\begin{document}
\num[parse-numbers = false]{\frac{7}{2}}
\end{document}

to use a fraction now.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • 1
    I agree with the design-choice, but the manual could have required a slightly more detailed chanegelog/deprecation info with conversion info... – JE_Muc Dec 27 '21 at 18:38
  • What about “fractions” inputed as 7÷2? How is that semantically very different from 7×2? Also, is there a way for \numproduct{7×2} to work like it use to do before with input-product = ×? – Archange Dec 29 '21 at 12:46
  • And finally, how do I make something like \numlist{1.2×3;3.4×2.15;0.200×1.40;44÷1.1} work without resorting to parse-numbers = false? – Archange Dec 29 '21 at 12:49
  • (I can open new questions for each if you prefer, but I thought they are all related to the switch to numproduct) – Archange Dec 29 '21 at 13:21
  • 1
    @Archange The semantics for \numproduct are really for the case 2m x 2m for say a piece of wood: this is not the same as saying the surface area is 4m^2, and certainly isn't like 2m / 2m. – Joseph Wright Dec 29 '21 at 22:29
  • @JosephWright But then those are \qtyproduct. And even then I see reasons for allowing such cases, for instances when one want to produce exact fraction of a quantity (think about e.g. the Debye definition or defining one arcmin in degrees). Is that really unreasonable to expect 7÷2 to work (by printing exactly that, not some math fraction)? And what about upgrading input-product = × to 3.x? – Archange Jan 03 '22 at 14:07
  • When I use \num[parse-numbers = false]{\frac{7}{2}} in equation environment, nothing is printed. Does this means that fractions can no longer be used in siunitx? OK, for dimensionless quantities I could stop using siunitx at all, I am not sure what to do with others... – Pygmalion Feb 06 '24 at 09:51
  • @Pygmalion Without an example I can't help: this should print just fine – Joseph Wright Feb 06 '24 at 09:53
  • I am sorry, it suddenly started to work for both\num and \qty. Strange! – Pygmalion Feb 06 '24 at 09:58