With newest `chemmacros` package, `\usepackage{siunitx}` throws an error and automatic `locale` doesn't seem to work
(I suppose part of this is my fault for upgrading packages without reading changelogs!
Old environment:
-
chemmacros
5.11a (Tue Nov 24 22:11:55 2020) -
siunitx
3.0.37 (Sun Dec 5 11:41:30 2021)
New environment:
-
chemmacros
6.0a (Mon Jan 24 22:11:36 2022) -
siunitx
3.0.48 (Tue Feb 8 22:11:27 2022)
Issue part a
Old environment compiles no problem with the template + my own text that I've been running for the past 6 months or so.
New environment throws the following errors in main.log
:
01_Document_administration/a_Packages.tex:121: LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.121 \usepackage
[
You're in trouble here. Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
01_Document_administration/a_Packages.tex:121: LaTeX Error: Option clash for package siunitx.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.121 \usepackage
[
The package siunitx has already been loaded with options:
[]
There has now been an attempt to load it with options
[ detect-family=true, detect-mode=true, locale=US, mode=text, range-phrase={~to~}, range-units=single, retain-explicit-plus, retain-unity-mantissa=false,retain-zero-exponent=false, separate-uncertainty=true, ]
Adding the global options:
, detect-family=true, detect-mode=true, locale=US, mode=text, range-phrase={~to~}, range-units=single, retain-explicit-plus, retain-unity-mantissa=false,retain-zero-exponent=false, separate-uncertainty=true,
to your \documentclass declaration may fix this.
Try typing <return> to proceed.
I think this is because the new version chemmacros
already loads siunitx
as part of its spectroscopy
module:
Loading the chemmacros module `spectroscopy' ...
(C:\Users\awang\AppData\Local\Programs\MiKTeX 2.9\tex/latex/siunitx\siunitx.sty
Package: siunitx 2022-02-07 v3.0.48 A comprehensive (SI) units package
To fix this, I had to change the \usepackage[options]{siunitx}
to \sisetup[options]
.
Also, the package warned me of deprecated options
retain-unity-mantissa=false,% no mantissa for numbers like 1e4
retain-zero-exponent=false, % no exponent for numbers like 1e0
separate-uncertainty=true, % uncertainties are separated from numbers
which I changed to
print-unity-mantissa=false, % no mantissa (the "1") for numbers like 1e4
print-zero-exponent=false, % no exponent for numbers like 1e0
uncertainty-mode=separate, % uncertainties are separated from numbers
Issue part b
In the code
\sisetup{
...
locale=\SILangSpec, % set localization in package (Anthony: hard code this to US)
range-phrase={\SIRangePhrase}, % for unit range "4 to 10 K"
...
}
The locale=\SILangSpec
part doesn't seem to work, I get the following error:
01_Document_administration/a_Packages.tex:119: LaTeX3 Error: Key 'siunitx/locale' accepts only a fixed set of choices.
For immediate help type H <return>.
...
l.119 }
The key 'siunitx/locale' only accepts predefined values, and 'US' is not one
of these.
Setting it to locale={\SILangSpec}
throws the same error. Curiously, siunitx doesn't complain about range-phrase={\SIRangePhrase}
.
This is the relevant code block:
%------------------------------
% UNITS
%------------------------------
\newcommand{\SILangSpec}{} % set localization of SIunix package depending on the default language of the document
\newcommand{\SIRangePhrase}{}
\iflanguage{english}{%
\renewcommand{\SILangSpec}{US}%
\renewcommand{\SIRangePhrase}{~to~}%
}{%
\iflanguage{ngerman}{%
\renewcommand{\SILangSpec}{DE}%
\renewcommand{\SIRangePhrase}{~bis~}%
}{}%
}
% Since chemmacros already loads siunitx, we use sisetup to modify some settings
% and formatting of SI units
\sisetup{
...
locale=\SILangSpec, % set localization in package (Anthony: hard code this to US)
range-phrase={\SIRangePhrase}, % for unit range "4 to 10 K"
...
}