I'm having the following problem.
I'm trying to type up something in Danish, which means I want a comma for the decimal mark. Usually I have no issues doing this, I simply set
<<>>=
options(OutDec = ",")
@
However, in my current document this introduced an error I was having trouble locating at first. Specifically, I'd get an error message of the form ! Incomplete \iffalse; all text was ignored after line [x]
. Playing around a bit, it seems the error arises from a clash with siunitx. Setting OutDec = ","
appears to enclose numbers resulting from \Sexpr{}
in \text{}
while changing the decimal mark to a comma. Usually this isn't a problem, but \siunitx doesn't appear to like the combination of math mode and \text{}
. At least, I get the relevant error message from the following MWE:
\documentclass{article}
\usepackage{siunitx}
\begin{document}
$ \SI{\text{1}}{\meter} $
\end{document}
However, I'd rather like to continue being able to use \Sexpr{}
within \SI{}{}
and get the correct decimal mark.
Any ideas on how to fix this?
\text
in the first place. Also, even though comma is the correct decimal in Danish, you are allowed to use dot as the decimal point as long as you are consistent. Otherwise you will have to write any decimal number either with\SI
(if it has a unit) or using\num
if it s does not. This is very cumbersome, so often easiest to simply use dot for the decimal.\text
. And while I agree that using a dot is fine given consistency (I always do this myself), I've been specifically asked for this piece to follow the comma convention, so sadly this is not an option.\sisetupcpy-decimal-marker}
if your input uses a comma?\sisetup{output-decimal-marker = {,}}
, but to no avail.