10

Is there a way to extract the multiplication factor that each siunitx prefix represents. Basically, can I automate ExplainPrefix to correctly produce the correct output. Current output uses x as the exponent:

enter image description here

MWE:

\documentclass{article}

\usepackage{siunitx} \usepackage{expl3}

%% http://tex.stackexchange.com/questions/100542/how-to-extract-the-name-of-a-macro \ExplSyntaxOn \newcommand{\CsToStr}[1]{\cs_to_str:N #1} \ExplSyntaxOff

\newcommand{\ExplainPrefix}[1]{% \par The prefix \CsToStr{#1} (symbol: \si{#1}) representes multiplication by $10^x$. }%

\DeclareSIPrefix\wacky{X}{41}

\begin{document}

\ExplainPrefix{\kilo} \ExplainPrefix{\micro} \ExplainPrefix{\wacky}

\end{document}

Peter Grill
  • 223,288

1 Answers1

12

You are looking for

\si[prefixes-as-symbols = false]{#1}

which will convert the prefix symbol to the value (a single stand-alone prefix is allowed here: I plan in figure to introduce some kind of 'no-op' unit to make the logic a bit easier).

The data for this conversion is stored in the internal property list \l__siunitx_prefix_forward_prop, which may of course change in the future but is there if you want to do something more complex.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036