Math & ScienceUnits of measure

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Oldak
Posts: 4
Joined: Tue Apr 05, 2011 12:01 pm

Units of measure

Post by Oldak »

Hi, I'm completely new to LaTeX (as of yesterday), but I've prepared a report in LaTeX, and it's working very well (thanks to Tobias Oetiker's The (Not So) Short Introduction to LaTeX2e).

I often need to use [number] [unit of measure] combinations such as: 32 mg kg^{-1} (i.e. 32 mg/kg ~matter of style preference). Which is the best practice to encode this?:
  • $32 mg kg^{-1}$
  • $32$ mg kg $^{-1}$
  • 32 mg kg $^{-1}$
If the first option is preferable, should all symbols representing units of measure be done in math mode? Any justification for (or not for) using math mode to render units of measure?

Thanks to anyone who can help.
Last edited by Oldak on Wed Apr 06, 2011 5:44 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Units of measure

Post by josephwright »

By hand, I would go for

Code: Select all

\( 32 \)\,mg\,kg\( ^{-1} \)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
using math mode for the mathematical content (using \mathrm for the units does work, but usually is over-kill). However, there are a number of more semantic approaches to the problem. I'd point to my own siunitx package, where the same effect as the above is available using

Code: Select all

\SI{32}{mg.kg^{-1}}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
or

Code: Select all

\SI{32}{\mg\per\kg}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I prefer the later, more semantic, approach, for which you'll need to load abbreviated units

Code: Select all

\usepackage[load-configurations = abbreviations]{siunitx}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Joseph Wright
Oldak
Posts: 4
Joined: Tue Apr 05, 2011 12:01 pm

Re: Units of measure

Post by Oldak »

Great! Many thanks for your advice. I'll give your siunitx package a spin, it looks like it does what I need.
Oldak
Posts: 4
Joined: Tue Apr 05, 2011 12:01 pm

Re: Units of measure

Post by Oldak »

I've been implementing siunitx for use with the report I am writing. I want to output "300–350g" (ndash, not hyphen). Using \SIrange{300}{350}{\gram}, the output is "300g to 350g". I've tried some quick hacks such as \SI{300}–{350}{\gram} which does output something similar to what I'm aiming for, except that the ndash is misaligned (the first number is followed by a small space). While skimming your documentation, I couldn't find a solution to this.

Is there an option for \SIrange to express the range using an ndash, with the unit following the end of the range (300–350g)?

P.S. \SI{3}{\gram\per\liter} results in "3 g L^{-1}". Is there an option to place a \cdot between "g" and "L" for the sake of clarity? Also, why does \litre result in "l" and \liter result in "L"? (I thought only "L" was acceptable.)
Last edited by Oldak on Wed Apr 06, 2011 5:48 pm, edited 1 time in total.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Units of measure

Post by localghost »

Oldak wrote:[…] While skimming your documentation, I couldn't find a solution to this.

Is there an option for \SIrange to express the range using an ndash, with the unit following the end of the range (300–350g)? […]
Actually the siunitx manual is quite clear in this regard. Searching the manual for „range“ with the search function of your PDF viewer gives you all necessary information, e. g. Table 16 and Table 23 (see code below}.
Oldak wrote:[…] \SI{3}{\gram\per\liter} results in "3 g L^{-1}". Is there an option to place a \cdot between "g" and "L" for the sake of clarity? […]
According to Section 5.10 of the manual this separator is also given by an option (see code below).

Code: Select all

Code, edit and compile here:
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{siunitx}
\usepackage{fix-cm}
\sisetup{%
load-configurations=abbreviations,
inter-unit-separator=\cdot,
output-decimal-marker={.},
range-phrase={--},
range-units=single
}
\begin{document}
\SIrange{300}{350}{\g}
\SI{3}{\g\per\liter}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Oldak wrote:[…] Also, why does \litre result in "l" and \liter result in "L"? (I thought only "L" was acceptable.) […]
The according Wikipedia article has an explanation [1]. The German version of this article says that the „L“ has been introduced in order not to mix it up the „l“ with the digit „1“. Both symbols are accepted. I think the package just accommodates to that.

[1] Litre — Wikipedia, the free encyclopedia


Best regards and welcome to the board
Thorsten
Oldak
Posts: 4
Joined: Tue Apr 05, 2011 12:01 pm

Units of measure

Post by Oldak »

Many thanks localghost, the \sisetup example you give is exactly what I needed. It seems I could have read the documentation a bit more thoroughly. :)

Edit: Although if anyone intends to use localghost's example, replace "\cdot" with "{}\cdot{}", per the documentation advice (p38):
The standard setting is a thin space: another common choice is a centred dot. To get the correct spacing it is necessary to use {}\cdot{} in the later case.
Soraiaq
Posts: 1
Joined: Thu Jan 19, 2023 4:47 pm

Units of measure

Post by Soraiaq »

Hello everyone,

I actually have a question according the \litre (l) - \liter (L) - situation.
I am using die SI-Unitx package in my report and needed to change the Liter-Character L to l. But despite the fact that I rewrite those spots from \liter to \litre I still get the L-Character as an output.
Am I doing something wrong or does LaTeX play games with me?

Thanks in advance for your answer and best regards,
Melike
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Units of measure

Post by rais »

well, nowadays \liter is defined as

Code: Select all

\DeclareSIUnit\liter{\litre}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
so if you put

Code: Select all

\DeclareSIUnit{\litre}{l}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
into your preamble, you should get what you want---with \liter and \litre alike.
See section `Adjusting \litre and \liter' in siunitx documentation.

KR
Rainer
Post Reply