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 »

Joseph,
I am using Lyx as my front end but I dont think this make any difference. Testing following code

Code: Select all

\documentclass[oneside,british,oldfontcommands]{memoir}
\usepackage{babel}
\OnehalfSpacing
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\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
\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}

\makeatother

\begin{document}
\begin{center}
Where short term stability is $\SI{10(1)}{\nano\second}$ as well as $\SI{10(1)}{\ns}$, but our network edge is $\SI{10}{\km}$.
\par\end{center}
\end{document}
Show no display difference between $\SI{10(1)}{\nano\second}$ and $\SI{10(1)}{\ns}$ despite different settings

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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

siunitx converstion of units

Post by cgnieder »

I can confirm LKB's observation. This MWE

Code: Select all

\documentclass{article}
\usepackage{siunitx}

\sisetup{
  scientific-notation=false,
  prefixes-as-symbols=true
}

\DeclareSIUnit[scientific-notation=engineering,prefixes-as-symbols=false]{\second}{s}
\DeclareSIUnit[scientific-notation=engineering,prefixes-as-symbols=false]{\ns}{\nano\second}

\begin{document}

\SI{10e2}{\nano\second}
\SI{10e2}{\kilo\metre}

\end{document}
on TL 2012 with »siunitx« v2.5g gives
siunitx.png
siunitx.png (2.25 KiB) Viewed 8521 times
site moderator & package author
LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

Re: siunitx converstion of units

Post by LKB »

Is there any more news on this one? Does it mean that unit specific definition cannot be made?
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

siunitx converstion of units

Post by josephwright »

Per unit settings work for that unit command alone: settings for \second will not apply to \ns, for example.
Joseph Wright
LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

siunitx converstion of units

Post by LKB »

If you look at Klemens example it does not work. Unit only definitions are not applied in the document in comparison to general command using \sisetup.

I think that way around it would be

Code: Select all

\newcommand*{\FlexUnits}[2]{\SI[scientific-notation=engineering,prefixes-as-symbols=false]{#1}{#2}}
but is not as nice nor flexible as using siunitx only
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

siunitx converstion of units

Post by josephwright »

It does work, but as I say only for exactly the units set up

Code: Select all

    \documentclass{article}
    \usepackage{siunitx}

    \sisetup{
      scientific-notation=false,
      prefixes-as-symbols=true
    }

    \DeclareSIUnit[scientific-notation=engineering,prefixes-as-symbols=false]{\second}{s}
    \DeclareSIUnit[scientific-notation=engineering,prefixes-as-symbols=false]{\nanosecond}{\nano\second}
    \DeclareSIUnit[scientific-notation=engineering,prefixes-as-symbols=false]{\ns}{\nano\second}

    \begin{document}

    \SI{10e2}{\nanosecond}
    \SI{10e2}{\ns}

    \end{document}
Joseph Wright
LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

Re: siunitx converstion of units

Post by LKB »

Compiled it shows different behaviour pattern for \nanosecond and \ns. It seems like I can re-define existing units and have to create new ones only. Is this correct?
Attachments
Results in Lyx
Results in Lyx
a.png (8.33 KiB) Viewed 8484 times
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

siunitx converstion of units

Post by josephwright »

Settings per unit only apply to exactly that unit command. So \nanosecond and \ns are different: if you want to cahnge how \ns behaves you will need to redefine it. The reason for this is that with compound units what 'should' happen rapidly becomes impossible to tell. So siunitx only checks for a set of options for the 'outer' unit (the one you actually type in), and not for what that then is converted to.
Joseph Wright
Post Reply