Math & Science ⇒ Using SI units
-
- Posts: 120
- Joined: Fri Nov 14, 2008 9:40 pm
Using SI units
Hello everybody,
I have seen some packages for the writing of the SI (Système International) units in documents. I often write documents about Physics, so I have to use these units, but I simply wonder if it is important to use these packages or not. I also want to know how do the physicists, about this.
Thanks!
I have seen some packages for the writing of the SI (Système International) units in documents. I often write documents about Physics, so I have to use these units, but I simply wonder if it is important to use these packages or not. I also want to know how do the physicists, about this.
Thanks!
NEW: TikZ book now 40% off at Amazon.com for a short time.

Using SI units
For simple expressions, it's not necessary:
But this method can become tedious, and it's often done wrong:
The latter means the multiplication of the variables k and g by 0.002, not 0.002 kilograms; furthermore, the multiplication sign is wrong. Packages for SI units help writing these expressions. A comprehensive package is siunitx, which could be used to simplify this quantity:
The aim of siunitx is to replace eventually all existing unit formatting packages. It comes with an extensive manual that describes all features and also their correct application.
Code: Select all
2 \cdot 10^{-3}\,\textup{kg}
Code: Select all
2*10^{-3} kg
Code: Select all
\SI{2e-3}{kg}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Using SI units
As a physicist, I feel directly addressed with this request. I also write lots of physical (and chemical) formulas. Not aware of any package, I started with formatting mathematical expressions containing units on my own. Since this can become very confused, I appreciate packages that save me a lot of time in typesetting this. I started with the simply structured units package and currently I'm using siunitx. The advantage of such packages is that they control things like text shape and spaces within the units and often simplify the input of number formats. You can rely on the fact that those packages typeset units as demanded.latexforever wrote:[...] I have seen some packages for the writing of the SI (Système International) units in documents. I often write documents about Physics, so I have to use these units, but I simply wonder if it is important to use these packages or not. I also want to know how do the physicists, about this. [...]
Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 120
- Joined: Fri Nov 14, 2008 9:40 pm
Using SI units
Thanks for these very useful pieces of information. The package siunitx seems to be the most used one nowadays, and I also think it is better than the units package.
-
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
Re: Using SI units
Just to chime in as the author of siunitx. I do hope that is is "better" than the competition: this was the aim when writing it :-)
--
Joseph Wright
--
Joseph Wright
Joseph Wright
-
- Posts: 120
- Joined: Fri Nov 14, 2008 9:40 pm
Using SI units
Thanks, josephwright. It is really a good package. Just a question, if I may: when using command, I've looked in the documentation of your package, but how do I always specify the decimal symbol to be the comma? I've seen , but it seems not to work in my preamble. Here are my options:
.
But when I use: in my document (it is evidently in a tabular environment), I receive:
Invalid character `4,186' in numerical input. It is the same thing when I use a dot at the place of the comma. What's the matter? Thanks!
Code: Select all
\num
Code: Select all
decimalsymbol=comma
Code: Select all
\usepackage[allowzeroexp=true,numdigits,obeymode=true,redefsymbols,textcelsius,textdegree,textminute,textmu,load={abbr,addn},decimalsymbol=comma]{siunitx}
But when I use:
Code: Select all
Calorie & $\cal$ & $\num{4,186}\SI{}{J}$\\
Invalid character `4,186' in numerical input. It is the same thing when I use a dot at the place of the comma. What's the matter? Thanks!
Re: Using SI units
What is the column type in your example? For guidelines about how to use siunitx for setting tabular material, please read sections 5 and 20.5 of the documentation.
-
- Posts: 120
- Joined: Fri Nov 14, 2008 9:40 pm
Using SI units
The problem is not only present in tabular environments. Even when I writephi wrote:What is the column type in your example? For guidelines about how to use siunitx for setting tabular material, please read sections 5 and 20.5 of the documentation.
Code: Select all
$\num{4,186}\SI{}{J}$
Code: Select all
\SI{}{J}$
Using SI units
The problem is the numdigits option, it expects a character string which is interpreted as digit list. If you don't provide a string, an empty one is taken and thus no character counts as digit. Just leave the entire option out.
Anyway, I recommend that you reread the siunitx documentation. A code likedoesn't make any sense to me. Neither \num nor \SI require math mode, and the result is exactly the same without the dollar signs unless you use text figures (but in that case it would be better to redefine the mode option if required). \SI is meant for quantities composed of a number and a unit, it is useless if you don't provide a number, since in this case it's equivalent to \si which is the command intended to typeset units. Typography rules demand a small space between units and numbers, which your code lacks. After all, your code looks as if you wanted to write a simple quantity (4.186 joules); this shall be done using
or
Neither the math mode switches nor the separate \num command are required.
Anyway, I recommend that you reread the siunitx documentation. A code like
Code: Select all
$\num{4,186}\SI{}{J}$
Code: Select all
\SI{4,186}{J}
Code: Select all
\SI{4,186}{\joule}
-
- Posts: 120
- Joined: Fri Nov 14, 2008 9:40 pm
Re: Using SI units
Thanks for your message.
In fact, I used dollars to test something. I was sure I hadn't understood something in the documentation of this package. I don't know why this wasn't clear to me.
Your explanations are clear, and I have understood. Anyway, I'll read a second time the package's documentation.
Thanks for your message.
In fact, I used dollars to test something. I was sure I hadn't understood something in the documentation of this package. I don't know why this wasn't clear to me.
Your explanations are clear, and I have understood. Anyway, I'll read a second time the package's documentation.
Thanks for your message.