Customising exponents in siunitx

Typesetting SI units in LaTeX can be done using the siunitx package.  One disadvantage is that siunitx doesn’t like math-mode inside the numbers it has to print. This makes it a little tricky to add unusual exponents or do other formatting that is easy in math-mode.  Therefore, siunitx includes a parser that figures out such things as \SI{5 x 2}{\metre} should appear as follows:

formula1

Another use is typesetting numbers with exponents, such as the following:


\SI{.23e7}{\candela}

The “e7” results in the exponent latex_6ab6133230db0c62062503c6388e78a0 being included producing the following output:

formula2

What if you want a different exponent that has meaning in your specific field?  Fortunately, siunitx includes a method for you to define new exponents:


\SI[exponent-base=1024, input-exponent-markers=k]{5k2}{elements\per\second}

This produces the following:

formula3

I found this solution here.  The other solution is to disable the parser by using parse-numbers=false like in this example from the siunitx documentation:


\SI[parse-numbers=false]{\sqrt{3}}{\metre}

This allows all math-mode commands to be used.  The resulting output is:

formula4-v3

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s