I often put comments in my documents to remind me where a number comes from:
\SI{39.68}{\milli\metre} deep % 0.31 * 128
I'd like LaTeX to calculate the product by itself. I wrote a function to do that with fp
, and it works (although I'd like a shorter one). But it doesn't work within \SI
:
\newcommand{\mult}[2]{%
\FPmul{\tempSum}{#1}{#2}%
\FPround\roundedSum\tempSum2%
\roundedSum%
}
\mult{0.31}{128} mm deep % works
\SI{\mult{0.31}{128}}{\milli\metre} deep % does not work
How to solve this?
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! siunitx error: "invalid-number"
!
! Invalid numerical input '\edef {\FP@mul \tempSum 0.31..\relax 128..\relax
! }\edef {\FP@round \roundedSum ..\relax }{2}'.
!
! See the siunitx documentation for further information.
!
! For immediate help type H <return>.
!...............................................
\SI[parse-numbers=false]
. Maybe you are also interested in a L3 multiplication:\ExplSyntaxOn \NewDocumentCommand \mult { m m } { \fp_eval:n { round( #1 * #2 ,2 ) } } \ExplSyntaxOff
– Marco Daniel May 16 '13 at 16:41