TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}
share|improve this question
up vote 12 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.