Math & ScienceUsing SI units

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
latexforever
Posts: 120
Joined: Fri Nov 14, 2008 9:40 pm

Using SI units

Post by latexforever »

Here is the reason why I used dollars.

When I write

Code: Select all

\SI{1,60218\cdot 10^{-19}}{J}
, I receive an error: Package siunitx Error: Invalid character[...]\si@out@minus 19}}} in numerical input.

I suppose I must have forgotten an option to load the package. If so, I shall look in the package's documentation. But if it is not the case, can somebody tell me what is my mistake? Thanks!

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Using SI units

Post by localghost »

I think phi already pointed out how to typeset this number format.

Code: Select all

\SI{1,60218e-19}{C}
So, a closer look at the documentation would be good.
latexforever
Posts: 120
Joined: Fri Nov 14, 2008 9:40 pm

Using SI units

Post by latexforever »

localghost wrote:I think phi already pointed out how to typeset this number format.

Code: Select all

\SI{1,60218e-19}{C}
So, a closer look at the documentation would be good.
Ok. I thought we were not obliged to use this notation. There is no problem. Thanks.
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: Using SI units

Post by josephwright »

I'll think about it, but I doubt I can (automatically) accommodate both "literal" and parsed input for \num (and \SI{<here>}). The parser to convert "1e10" to "1 \times 10^{10}" has to do expansion so that people can use macro-based input. Perhaps I'll add a manual option. I'll see!
--
Joseph Wright
Joseph Wright
latexforever
Posts: 120
Joined: Fri Nov 14, 2008 9:40 pm

Re: Using SI units

Post by latexforever »

Thanks. It was not a suggestion. Just an user's mistake! :)
Effectively, I think it is a little bit more complicated to implement.

Good night.
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: Using SI units

Post by josephwright »

Just like to see what users are doing: sometimes good or important ideas pop up unexpected.
--
Joseph Wright
Joseph Wright
latexforever
Posts: 120
Joined: Fri Nov 14, 2008 9:40 pm

Using SI units

Post by latexforever »

Just another question: why does the package automatically writes dB when we use

Code: Select all

\deci\bel
, and writes dB, when we use

Code: Select all

\si{dB}
?

Thanks
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Using SI units

Post by phi »

This is not the case with version 1.1j, at least not in the following document:

Code: Select all

\documentclass{article}

\usepackage{siunitx}


\begin{document}

\si{\deci\bel}

\si{dB}

\deci\bel

\end{document}
Please provide an MWE, as usual.
Note that the recommended way for writing units is to use the \si command, like in the first or second line. Free-standing units don't work reliably in all cases. So the preferred way for expressing decibels is given by the first line.

@Joseph Wright: I think that it would be nice to have a mode where free-standing units are completely disabled, and unit macros are only allowed inside \SI or \si. This would reduce the possibility of overwriting other macros, and more abbreviated unit names would be possible. This is similar to the TikZ/PGF bundle, whose macros are only allowed inside certain environments, and thus can have very concise names without namespace pollution.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Using SI units

Post by localghost »

The older version 1.0i also gives a correct output. Perhaps a matter of an outdated version on your system.
latexforever
Posts: 120
Joined: Fri Nov 14, 2008 9:40 pm

Re: Using SI units

Post by latexforever »

Thanks for these answers.
Post Reply