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:


    $ \SI{\text{1}}{\meter} $

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?

  • Why is knitr adding \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.
    – daleif
    Dec 12, 2016 at 18:52
  • Not sure why knitr adds \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.
    – MSR
    Dec 12, 2016 at 19:08
  • Did you try \sisetupcpy-decimal-marker} if your input uses a comma?
    – Bernard
    Dec 12, 2016 at 19:18
  • Even after some googling I'm afraid I'm not quite sure what this was meant to say (if it's a typo - otherwise I'm even more clueless). I have tried \sisetup{output-decimal-marker = {,}}, but to no avail.
    – MSR
    Dec 12, 2016 at 19:58

1 Answer 1


Why don't you use the following to get the correct decimal mark:

\sisetup{output-decimal-marker = {,}}

$\SI{1,5}{\meter}$ % ',' works, too
  • Presumably because a lot of his doc is being generated by knitr (the orig doc being a mixture of R and LaTeX)
    – daleif
    Dec 12, 2016 at 20:48
  • That's a perfectly good solution for a standard latex. My problem arises, though, when I try to pass the numerical value of x in \SI{x}{} via \Sexpr{} using knitr. For this, I'm not sure this helps.
    – MSR
    Dec 12, 2016 at 20:49
  • The answer is correct for a .Rnw file too. There are not problem to change in this example 1.5 by \Sexpr{a} where for instance a <- 4.3 (with dot). This will print 4,3 with comma and without error. As demonstrated just the MWE of the question, the problem is not related in any form with R but with the use of \text{} inside the first argument of \SI, that have not sense.
    – Fran
    Sep 12, 2017 at 1:04

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.