5

im currently working on my Master's Thesis and i need siunitx for my SI units. The problem hereby is, that somehow my code doesnt generate the normally installed spaces between the number and the unit. Here is my code

\documentclass[11pt,a4paper,oneside,titlepage]{scrbook}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
%Codierung
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[locale = DE, quantity-product = {,},exponent-product = \cdot]{siunitx}
\sisetup{locale = DE, per-mode=reciprocal-positive-first}
\begin{document}

Example for SI unit: \SI{0.15}{\cubic\meter\per\gram}

\end{document}

The resulting sentence would be: 0.15m^3 g^-1

The space between the m^3 and g^-1 works somehow, but the one between the count and unit doesnt..It would be great, if someone could help me with this problem.

Thank you in advance.

3 Answers 3

7

You should remove the quantity-product = {,} option. This sets the symbol to be used between the number and the unit, and is set to \, by default. In your MWE it does nothing because it should be set in \sisetup instead of passed as an option to the package.

\documentclass[11pt,a4paper,oneside,titlepage]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[locale = DE]{siunitx}
\sisetup{exponent-product = \cdot,per-mode=reciprocal-positive-first}
\begin{document}

Example for SI unit: \SI{0.15}{\cubic\meter\per\gram}

Example for SI unit: \SI[quantity-product = {,}]{0.15}{\cubic\meter\per\gram}
\end{document}

enter image description here

2

Unit spacing with siunitx in an equation

enter image description here

\documentclass[11pt,a4paper,oneside,titlepage]{scrbook}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
%Codierung
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[locale = DE, quantity-product = {,},exponent-product = \cdot]{siunitx}
\sisetup{locale = DE, per-mode=reciprocal-positive-first}
\begin{document}

Example for SI unit:  \SI{0.15}{\cubic\meter\per\gram}

Another Example for SI unit:   \num{0.15}\,\si{\cubic\meter\per\gram}


\end{document}
1
  • Oh thank you so much, both of you :) It worked finally! Have a good day! Nov 4, 2021 at 5:29
2

By design (perhaps faulty, but it has been so for about 30 years), braces in the optional argument to \usepackage are essentially ignored, so what you get from

\documentclass[11pt,a4paper,oneside,titlepage]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[
  locale = DE,
  quantity-product = {,},
  exponent-product = \cdot,
]{siunitx}

\sisetup{locale = DE, per-mode=reciprocal-positive-first}

\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}

\begin{document}

Example for SI unit: \SI{0.15}{\cubic\meter\per\gram}

\end{document}

(I reorganized a bit the preamble) is the same as

\usepackage[
  locale = DE,
  quantity-product = ,,
  exponent-product = \cdot,
]{siunitx}

and so quantity-product receives the empty value and there's an empty option that is ignored.

On the other hand, you don't want to set quantity-product to a comma, do you?

\documentclass[11pt,a4paper,oneside,titlepage]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[
  locale = DE,
  quantity-product = \,,
  exponent-product = \cdot,
]{siunitx}

\sisetup{locale = DE, per-mode=reciprocal-positive-first}

\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}

\begin{document}

Example for SI unit: \SI{0.15}{\cubic\meter\per\gram}

\end{document}

works well. But since you're going to use \sisetup anyway, just set all options there, without duplications:

\usepackage{siunitx}
[...]
\sisetup{
  locale = DE,
  quantity-product = \,,
  exponent-product = \cdot,
  per-mode=reciprocal-positive-first,
}

I recommend to separate settings from package loading. The preamble becomes clearer and more easily maintained.

By the way, quantity-product=\, is the default, so there's no need to set it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .