2

Does siunitx take mixed decimal inputs like 0,004319689898685966 and 0.004319689898685966? It looks like it, but is it intended to work like this?

I am using Python for my calculations with a "." decimal symbol and manually type with a "," decimal symbol.

Image: enter image description here

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\sisetup{range-phrase=-,
            detect-all,
            decimalsymbol=comma,
            round-mode=places,
            round-precision=4,
            range-units=single,
            per-mode=fraction,}

\begin{document}

\begin{itemize}
\item \SI{0,004319689898685966}{\meter \squared}
\item \SI{0.004319689898685966}{\meter \squared}
\end{itemize}
\end{document}
1
  • 1
    It is intentional. There are settings for what it should look for and what it should normalise the output to
    – daleif
    Aug 28, 2020 at 10:13

2 Answers 2

4

Since input data for \SI might come from various sources, one can use various styles for it; in particular a decimal period or a decimal comma in the input is converted to use a marker that's set with output-decimal-marker.

The key decimalcomma is still allowed for it, but it issues a warning

Package siunitx Warning: Version 1 option 'decimalsymbol' detected.

There are various options to comply with different input styles, but at the end the output is always normalized according to the chosen options regarding the decimal marker, the group separations and so on.

Options can be set globally (but respecting TeX groups) with \sisetup or locally with an optional argument to \SI.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\sisetup{
  range-phrase=-,
  detect-all,
  output-decimal-marker={,},
  round-mode=places,
  round-precision=4,
  range-units=single,
  per-mode=fraction,
}

\begin{document}

\begin{itemize}
\item \SI{0,004319689898685966}{\meter \squared}
\item \SI{0.004319689898685966}{\meter \squared}
\item \SI[output-decimal-marker=.]{0.004319689898685966}{\meter \squared}
\sisetup{output-decimal-marker=\ensuremath{{\cdot}}}
\item \SI{0.004319689898685966}{\meter \squared}
\end{itemize}
\end{document}

enter image description here

3

The siunitx package distinguishes between

  • input-decimal-markers, with default ,., i.e., both comma and period (aka "full stop") are interpreted as decimal marker, and

  • output-decimal-marker, which defaults to . (period).

A compilable example:

\documentclass{article}
\usepackage{siunitx}
\begin{document}
\num{0.333} and \num{0,333}

\sisetup{output-decimal-marker={,}} % change the default

\num{0.333} and \num{0,333}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.