Graphics, Figures & Tablessiunitx converstion of units

Information and discussion about graphics, figures & tables in LaTeX documents.
LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

siunitx converstion of units

Post by LKB »

With following settings

Code: Select all

\sisetup{input-product=x , output-quotient =  \ensuremath { { } \times{}}}
\sisetup{scientific-notation = engineering, prefixes-as-symbols=false}
this code

Code: Select all

\SI{1.2x0.8}{\km}

will produce 1.2*10^3m x 800*10^-3*10^3m. Is there any option to force siunitx to recognise that 10^-3*10^3==1 and produce much more desirable 1.2*10^3m x 800 m

thank you

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

Re: siunitx converstion of units

Post by LKB »

I really suspect that this can be done. Can anybody point me proper direction?
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: siunitx converstion of units

Post by cgnieder »

I'm not quite so sure this can be done but maybe Joseph Wright, the package author, reads this post and has a more qualified answer.

Regards
site moderator & package author
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: siunitx converstion of units

Post by josephwright »

At present, the answer here is 'no'. The facility in siunitx to convert prefixes to numbers essentially 'stands alone' from the numbers themselves, and is quite simple-minded really. I will see if there is an easy way to extend the code here: I will need to examine the detail to remind myself of the processing order.
Joseph Wright
LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

Re: siunitx converstion of units

Post by LKB »

If its possible this would be great. If not, I will have to stop using prefixes conversion.

Thank you,
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: siunitx converstion of units

Post by josephwright »

I've taken a look at this, and at present it's neither possible nor easy to set up. Broadly, while siunitx is flexible it does not have entirely independent parsing and formatting steps. I know that this probably needs altering long-term, but it is not something I plan to tackle soon. (It's very complex and is only needed for edge cases.)
Joseph Wright
LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

siunitx converstion of units

Post by LKB »

I see.
I meantime, is it possible to globaly change display pattern for specific units? Currently I set it up in preamble.

Usage for this setting was intended for the seconds as I prefer it to ns,ms,us ect. But this is not so useful when I deal with distances, areas and weights. If I could restrict

Code: Select all

\sisetup{scientific-notation = engineering, prefixes-as-symbols=false}
only to \second and its derivatives (\ns \ms ect) it would do a trick instead. Would this be possible?
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

siunitx converstion of units

Post by josephwright »

Each unit can have its own options: these work on a strictly per-unit basis. Thus you want something like

Code: Select all

\DeclareSIUnit[scientific-notation = engineering, prefixes-as-symbols=false]
  {\second}{s}
\DeclareSIUnit[scientific-notation = engineering, prefixes-as-symbols=false]
  {\ns}{\nano\second}
...
Joseph Wright
LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

siunitx converstion of units

Post by LKB »

Joseph,
It does not seems to work - unit wise settigns settings seems to be completely ignored.
I attach used code, could I be doing something wrong here?

Code: Select all

\usepackage{siunitx} %this is for units display
\sisetup{per-mode=fraction, tight-spacing = true , fraction-function = \tfrac , quotient-mode = fraction}%
\sisetup{inter-unit-product = \ensuremath { { } \cdot { } } , exponent-product = \cdot }%
\sisetup{input-product=x , output-quotient =  \ensuremath { { } \times{}}} %for 1x2x3
%number grouping(3), std==true %\sisetup{group-digits = decimal} 
\sisetup{group-minimum-digits = 4} %start grouping from 4 digits, in 3 no groups
\sisetup{range-units = single} %2-3C not 2C-3C
\sisetup{separate-uncertainty=true} %2+-1 not 2(1)
%\sisetup{scientific-notation = engineering }  % exp in multiple of 3
%\sisetup{prefixes-as-symbols=false} %10^-9 ect ect
\sisetup{zero-decimal-to-integer, round-mode = places,round-precision = 3}
\DeclareSIUnit[scientific-notation = engineering, prefixes-as-symbols=false]
  {\second}{s}
\DeclareSIUnit[scientific-notation = engineering, prefixes-as-symbols=false]
  {\ns}{\nano\second}
\DeclareSIUnit[scientific-notation = engineering, prefixes-as-symbols=false]
  {\ms}{\nano\second}
\DeclareSIUnit[scientific-notation = engineering, prefixes-as-symbols=false]
  {\us}{\micro\second}
\DeclareSIUnit[scientific-notation = engineering, prefixes-as-symbols=false]
  {\ps}{\pico\second}
\DeclareSIUnit[scientific-notation = engineering, prefixes-as-symbols=false]
  {\fs}{\femto\second}
\DeclareSIUnit[scientific-notation = engineering, prefixes-as-symbols=false]
  {\as}{\atto\second}
\DeclareSIUnit[prefixes-as-symbols=true]
  {\km}{\kilo\meter}
I change the order of things and results are always the same. Unless I define the behaviour globally via \sisetup, it will not work.
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: siunitx converstion of units

Post by josephwright »

Could you add a 'document' part, so I can see how you are using this?
Joseph Wright
Post Reply