I am writing a multi-language document in latex.
I am using siunitx package in conjonction with babel to handle every numerical and units related numeric values.
My goal was to declare a new unit (for instance \fps) which would output differently depending on the locale selected.
I was thus thinking of something like this :
\documentclass[french,english]{book}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{siunitx}
\sisetup{range-units = single}
\addto\extrasfrench{%
\sisetup{locale = FR, group-separator = {\,}, detect-all}%
\DeclareSIUnit[number-unit-product = \text{~}]{\fps}{images\text{~}par\text{~}seconde}}
\addto\extrasenglish{\sisetup{locale = US, group-separator = {,}, detect-all}%
\DeclareSIUnit[number-unit-product = \text{~}]{\fps}{frames\text{~}per\text{~}second}}
\begin{document}
English: \SIrange{5}{6}{\fps}
\begin{otherlanguage}{french}
Français: \SIrange{5}{6}{\fps}
\end{otherlanguage}
\end{document}
Unfortunately this idea cannot work since the
\DeclareSIUnit[number-unit-product = \text{~}]{\fps}{frames\text{~}per\text{~}second}
macro is then executed within the document and thus resulting in an error ?
Any idea ?
Thank you.
\text{~}
?\newcommand*\fpsname{frames per second}\newcommand*\fps[1]{\num{#1}~\fpsname}
and then change\fpsname
in the usual way when switching languages.m
are symbols not name or abbreviations).siunitx
just wasn't the right one?