5

In the manual, unless I am mistaken, it says to replace \si by \unit.

But I have this error:

Package siunitx Error: Found prefix part with no unit.

How can I make this document compatible with the new version 3 of siunitx?

\documentclass[aspectratio=1610,10pt,french]{beamer}

\usepackage[french]{babel} \usepackage[output-decimal-marker={,}]{siunitx}

\begin{document} \begin{frame} % \sisetup{color = blue}

\begin{tabular}{l l l} kilo $=1000$ & noté \unit{\kilo} &\rule[2mm]{0pt}{5mm} Exemples:\ \unit{\kilo\metre}; \unit{\kilo\gram};% \ % hecto $=100$ & \repete{noté} \si{\hecto} &\rule[2mm]{0pt}{5mm}\repete{Exemple:}\ \ \si{\hecto\meter}; \si{\hecto\gram}; \si{\hecto\liter}\ % deca $=10$ & \repete{noté} \si{\deca}& \rule[2mm]{0pt}{5mm}\repete{Exemple:}\ \ \si{\deca\meter}; \si{\deca\gram}; \si{\deca\liter}\ % déci $=0.1=\dfrac{1}{10}$ & \repete{noté} \si{\deci} & \rule[2mm]{0pt}{5mm}\repete{Exemple:}\ \ \si{\deci\meter}; \si{\deci\gram}; \si{\deci\liter} \ % centi $=0.01=\dfrac{1}{100}$ & \repete{noté} \si{\centi} & \rule[2mm]{0pt}{5mm}\repete{Exemple:}\ \ \si{\centi\meter}; \si{\centi\gram}; \si{\centi\liter}\ % milli $=0.001=\dfrac{1}{1000}$ & \repete{noté} \si{\milli} & \rule[2mm]{0pt}{5mm}\repete{Exemple:}\ \ \si{\milli\meter}; \si{\milli\gram}; \si{\milli\liter} \end{tabular}

\end{frame} \end{document}

AndréC
  • 24,137

1 Answers1

6

First off, you can use \si also with siunitx version 3, but it's deprecated and is present for back compatibility.

Second: a prefix must be followed by a unit; it wasn't enforced in version 2, now it is.

With a little stretch, you can define a \siprefix command:

\documentclass{article}
\usepackage{siunitx}

\NewDocumentCommand{\siprefix}{m}{% \unit{#1\nonexistentunitjustforprefixes}% } \DeclareSIUnit{\nonexistentunitjustforprefixes}{\relax}

\begin{document}

\siprefix{\kilo}

\end{document}

You could actually do \unit{k}, but this would defy the purpose of the package.

egreg
  • 1,121,712
  • You say that \si is back compatible but with version 3 \si{\kilo} doesn't work while it worked with version 2! – AndréC Sep 04 '21 at 20:57
  • 3
    @AndréC It sort of worked. But the documentation has always been adamant in saying that prefixes must be followed by units. – egreg Sep 04 '21 at 21:01
  • If I write \unit{k} instead of \unit{\kilo}, will the result be identical? – AndréC Sep 04 '21 at 21:03
  • 2
    @AndréC Just type k. – egreg Sep 04 '21 at 21:05
  • ok, can you add this possibility to your answer? – AndréC Sep 04 '21 at 21:07
  • @AndréC Added, with a comment. – egreg Sep 04 '21 at 21:11
  • it defy the purpose of the package, but it allows me to use \sisetup{color = blue} to color all units blue ! How to make it simpler then ? – AndréC Sep 04 '21 at 21:14
  • @AndréC I've retained the document commands from v2 but I decided not to try to make them 100% compatible, as there are significant changes to the font set up. As such, I retained exactly the v2 code using \usepackage{siunitx}[=v2] for cases where it's needed. – Joseph Wright Sep 05 '21 at 08:49
  • @JosephWright Thank you, but why did you decide to make units mandatory? I can understand it for academics, but when teaching children, our first job is to teach them the meaning of prefixes... – AndréC Sep 05 '21 at 14:44
  • @AndréC The use case of teaching/illustrating prefixes is very specialised. Obviously I have it myself for the package, and I therefore made sure I did have a way to do it in v3: what I wanted to avoid is having a special case in the code for an incredibly rare situation (almost always a dangling prefix is an error). – Joseph Wright Sep 05 '21 at 16:38