How do I produce something like "4 x 5 x (10–15) mm^3" in siunitx?
Thanks!
Best Answer
Package siunitx also supports expressions with multiple parts for the number. However, a range as number is not supported then. The following example uses a quotient instead and locally reconfigures, how quotients are printed. The second expression also adds the brackets that are a bit trickier.
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\SI[
product-units = power,
input-quotient = :,
output-quotient = \text{--},
quotient-mode = symbol,
]{4 x 5 x 10:15}{\mm}
\newcommand*{\myrange}[2]{%
(%
\numrange[
range-phrase = \text{--},
parse-numbers = false,% numbers are ready for printing
]{#1}{#2})%
}
\SI[
product-units =power,
input-quotient =:,
quotient-mode =fraction,
fraction-function =\myrange,
]{4 x 5 x 10:15}{\mm}
\end{document}
You are looking for the product-units option. It accepts one of five options. Their result is shown in the code sample.
Code
\documentclass[varwidth]{standalone}
\usepackage{siunitx}
\begin{document}\noindent
\begin{tabular}{ll}
\texttt{repeat} (default) & \SI[product-units=repeat] {4 x 5 x 6}{mm} \\
\texttt{single} & \SI[product-units=single] {4 x 5 x 6}{mm^3} \\
\texttt{power} & \SI[product-units=power] {4 x 5 x 6}{mm} \\
\texttt{brackets} & \SI[product-units=brackets] {4 x 5 x 6}{mm^3} \\
\texttt{brackets-power} & \SI[product-units=brackets-power]{4 x 5 x 6}{mm}
\end{tabular}
\end{document}
Best Answer
Package
siunitx
also supports expressions with multiple parts for the number. However, a range as number is not supported then. The following example uses a quotient instead and locally reconfigures, how quotients are printed. The second expression also adds the brackets that are a bit trickier.